   
 WEB- 
   MySQL 
  
 
1 
  -   
2003 

and 
Web 
Luke Welling and Laura Thomson 
SAMS 
201 West 103rd Street, Indianapolis, Indiana 46290 

 
Web- 
 PHP  MySQL 
     
 
  -   
2003 

 32.973.2 
77 
 
 Web-    MySQL: .  ,  -
 2- ., .  :  2003.  672 . 
ISBN 5-93772-090-3 
 Web-    MySQL    -
      MySQL      
Web-   . 
        -,  
    ,      . 
        ,  
,   PDF-,      
Web,    Web-.     --
,          ,  -
       -  
    Web. 
  CD-ROM    ,   ,   
 ,       Web-. 
    ,  ,      -
,            
         Internet. 
 32.973.2 
  
 ,   
 WEB-    MYSQL 
 .. 
  
 
  
 ϻ, 196105, -, . ., . 1, . 108. 
 000328  9  1999 
   10.03.2003.    16.04.2003.  
 .  .  . .. 42. 
.  3000 .   
            
    ,    
198005, -,  ., 29. 
Authorized translation from the English language edition, entitled PHP and MySQL Web Development, published 
by Sams, Copyright  2000 
All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or 
mechanical, including photocopying, recording or by any information storage retrieval system, without permission 
from the Publisher, 
Russian language edition published by DiaSoft Publishing. 
Copyright  2003 
   Sams Corporation,  Macmillan Computer Publishing. 
  ,             . 
5-93772-090-3 (.)     .  ϻ, 2003 
ISBN (.)  Sams Corporation, 2000 
 .  ϻ, 2003 
   77.99.6.953..438.2.99  04.02.1999 

  
 1.   25 
 1.    26 
 2.     59 
 3.   75 
 4.      95 
 5.       
 6. -    
 2.  MySQL 157 
 7.  Web-  158 
 8.  Web-  
 9.     MySQL 187 
 10.     MySQL  Web    203 
 11.   MySQL 216 
 3.     232 
 12.     233 
 13.      245 
 14.      MySQL 265 
 15.       MySQL 283 
 4.     301 
 16.       302 
 17.        
 18.     333 
 19.   340 
 20.     361 
 21.     374 

 
 5.    
   MySQL 380 
 22.    MySQL   
  
 23.  396 
 24.    
 25.   441 
 26.     477 
 27.   ,   Web 500 
 28.     529 
 29.  Web- 571 
 30.    
    (PDF) 596 
 6.  626 
 .   4  MySQL 627 
 .  Internet 645 
  648 

 
 
 1.   25 
 1.    26 
  27 
 : Auto Parts 27 
  27 
  29 
   HTML 29 
 PHP- 30 
 PHP- 30 
PHP- 31 
 31 
 32 
  33 
  33 
 date() 33 
    34 
  34 
  35 
   35 
 36 
,  36 
   36 
  36 
   37 
  37 
  37 
  38 
 :.... 38 
   39 
  39 
  39 
  40 
  40 
  
  44 
  44 
  45 
 : 
    46 
  : 
  47 
     48 
     48 
   49 
   50 
  50 
    
  50 
if 50 
  51 
:   
   51 
 else 51 
 elseif 52 
 switch 52 
   54 
:   54 
 while 55 
 for 56 
 57 
    
  58 
 2.   
  59 
     
 60 
    
   60 
   61 
  61 
  61 
  
   61 
    FTP 
 63 

8  
 
   64 
   65 
  65 
  65 
  66 
   67 
   : 68 
  : feof() 68 
 : 
 68 
  : 
file() 69 
 : fgetc() 70 
   : 
70 
    70 
  : file_exists() 70 
  : 71 
  71 
  : 
fseek  71 
  72 
   : 
    73 
,    
  73 
    
   74 
 3.  75 
   76 
   76 
   
 76 
    77 
      78 
  78 
   78 
    78 
    
 list() 79 
  80 
  83 
  83 
   
    83 
    83 
   84 
   
 84 
   
    85 
   
   86 
  86 
  array_reverse() 87 
    88 
    90 
  : 
 each, 
end(), next(), pos()  prev() 90 
     
 : array_walk() 91 
   :  
 92 
    
:  93 
 4.   
   95 
 : Smart Form Mail 95 
  97 
 : 
 chop(), ltrim()  trim() 97 
   98 
   : 
  StripSlashes() 
    
    101 
  
 join() 102 
  102 
  substr() 103 
  104 
 :  
strcasecmp()  104 

 
     
 104 
     
   105 
   :  
strchr(), stristr() 105 
  : 
 106 
 ; str_replace(), 
107 
    108 
    108 
 
 
  
      
 
   
   
    
   
  Smart Form 
    
  
    
  113 
    
  
    
   114 
 5.   
    115 
   
 ? 116 
 
 
 '. 
  
 116 
  
    
 
PHP-   
  
  Web- 
  
 122 
  123 
   125 
  125 
    126 
    127 
    
 ? 
   128 
  128 
 
  131 
     
  133 
   134 
    135 
  136 
 
 6. - 
   139 
 - 
 
   140 
 141 
 141 
 ,   
   142 
  142 
 142 
   143 
   143 
   145 
    146 
 146 
  148 
  148 
   149 

10  
2.  157 
 
Web-  158 
    
  159 
 159 
 159 
 159 
 160 
 160 
 161 
 161 
   
Web-  162 
   , 
   162 
    163 
   . 
   164 
  ,  
    165 
    
   165 
  165 
 Web-  166 
 166 
 8.  
Web-  168 
   
 MySQL 
   MySQL 170 
    
  171 
   171 
   171 
   
 MySQL 171 
   172 
 :  GRANT. 172 
    173 
 
   
  Web 176 
    root 176 
   176 
    177 
     178 
    178 
     
 SHOW  DESCRIBE 180 
 MySQL 181 
   182 
  182 
 9.     
MySQL 187 
  SQL? '... 187 
     188 
     189 
    
 191 
    
   : 
 196 
     197 
    198 
    199 
     200 
    200 
     202 
  202 
    202 
 10.     
MySQL  Web    203 
   Web- 204 
    
    Web 206 
   , 
   207 
  207 
   209 
     209 
   210 

 11 
    211 
   
   211 
   
  214 
     214 
  PHP-  214 
 11.  
 MySQL 216 
    216 
 user 217 
 db  host 218 
 tables_priv  
 :  MySQL 
   220 
 :   
  ? 221 
  
  MySQL 221 
MySQL     
 221 
 222 
  222 
 Web 223 
   
   223 
    SHOW 223 
    
  DESCRIBE 225 
    EXPLAIN 225 
    
   229 
   229 
  229 
  229 
  229 
  230 
 ,  
  230 
   230 
  230 
   230 
    231 
 3.   
   232 
 12.   
  233 
  233 
  Web- 234 
  234 
      237 
     240 
    241 
  241 
   242 
 242 
  243 
  243 
 ,   
 ,    243 
  243 
   244 
   244 
  
  , 244 
 13.   
   245 
   ? 246 
  246 
   247 
    248 
  249 
   250 
   251 
   252 
   
, 
   253 
   254 
  254 
  255 
  256 

12  
    257 
    258 
  258 
  259 
 Web- 260 
   262 
 262 
   263 
    263 
    
  MySQL 263 
  264 
 14.  
    MySQL 265 
  265 
   266 
  268 
  270 
   271 
  272 
  
   273 
    
   Apache .. 274 
  
  IIS 277 
   
 279 
  279 
? 280 
  281 
   
 281 
 15.   
    MySQL 283 
   283 
  284 
Internet 285 
  ... 286 
   
 ,  290 
   
    ? 292 
    292 
 GPG 293 
 GPG 295 
 4.   
  301 
 16.   
    
     302 
HTML-     303 
 PHP-     304 
   307 
   
  307 
   307 
    309 
    309 
    310 
    310 
   312 
,   
  312 
   313 
  : 
getenv()  putenv() 314 
 17.   
     316 
   316 
    317 
  Web- 
 317 
    320 
 FTP 323 
 FTP   
     323 

 13 
    329 
  - 329 
    329 
    
   cURL 330 
 18.    
 333 
    
  333 
  date() 333 
    UNIX 335 
  335 
   336 
    
  MySQL 336 
   338 
   338 
 19.   
     . 340 
  341 
JPEG 341 
PNG 341 
342 
GIF 342 
  343 
  344 
    
  344 
   346 
  347 
   
    347 
     
  347 
  350 
     350 
  352 
    353 
  353 
     353 
    359 
 20.   
 361 
    361 
   
  362 
  cookie-? 362 
 cookie-   363 
  363 
   364 
    364 
  364 
   365 
   365 
   
   365 
   366 
   368 
   
   368 
 21.   
  374 
   374 
 ,  
 , -  eval() 375 
 : die  exit 376 
 376 
    
  377 
   377 
   378 
   
  378 
   378 
    378 
    379 

14  
5.   
    380 
 22.    MySQL 
    . 381 
   
    
Web- 382 
   
 Web- 382 
   383 
   
  384 
   384 
 387 
  
  387 
   
   387 
  388 
   389 
  390 
  391 
    392 
  392 
   392 
   393 
 394 
  395 
  395 
 23.  396 
  396 
  397 
   398 
  402 
   
 404 
    405 
   
  406 
   408 
   408 
  
 24.   
 411 
 
  412 
   
 412 
  413 
  413 
  413 
   415 
   416 
  418 
 418 
   423 
   426 
  427 
   428 
    432 
 432 
  434 
  434 
  436 
    440 
 25.  
  441 
 442 
  442 
   442 
   442 
 443 
  443 
  443 
   447 
   449 
  451 
    453 
    454 

 15 
   455 
  456 
   458 
    460 
   
 462 
     
 462 
  463 
 467 
  
 469 
  475 
   .... 476 
 26.   
  477 
 477 
   478 
  478 
    478 
FTP 478 
    
    479 
  479 
  480 
  480 
  481 
  483 
   484 
 486 
  486 
  488 
  495 
  498 
  499 
 27.   
,   Web 500 
 500 
  '.. 501 
  502 
   503 
  505 
     509 
   511 
    513 
    
   515 
   516 
   516 
   518 
   521 
   523 
   524 
  525 
   525 
     527 
  528 
 28.   
  529 
 530 
  530 
     
 530 
  531 
   
   531 
  531 
   533 
  535 
  542 
    542 
 544 
   547 
   547 
     551 
    553 
    554 
   
  555 
  555 
   557 

16  
   557 
    558 
   559 
   562 
  
  565 
  566 
  570 
 29.  Web- 571 
  572 
  573 
   575 
   577 
  579 
  581 
  treenode 582 
   588 
   589 
  595 
   595 
 30.  
 
   
  596 
 596 
   597 
  597 
ASCII 598 
HTML 598 
   598 
   599 
PostScript 600 
   600 
  601 
    601 
   
  602 
  604 
  605 
  606 
 RTF- 608 
 PDF-  
 PDF-  
 PDFlib 614 
 Hello World  PDFlib 614 
    PDFlib 
,    624 
  625 
 6.  626 
 .  
 4  MySQL 627 
     
CGI   628 
 Apache, PHP  MySQL  629 
Apache  632 
  634 
   ? 635 
  SSL? 635 
 Apache, PHP  MySQL 
 Windows 636 
 MySQL  Windows 637 
 Apache  Windows 638 
   Apache 
 Windows  UNIX 640 
   Windows 641 
    Microsoft IIS . 643 
    Microsoft PWS . 644 
  644 
 .  Internet 
,   645 
,  MySQL  647 
,  Apache 647 
  Web 647 
  648 

 17 
  
  (Laura Thomson)      Web  
    RMIT  , . -
         Web-  
Tangled Web Design.      Telstra   -
  (Boston Consulting Group).      
 ( )        (-
  ),        -
         Web-.  -
   .       : 
laura@tangledweb.com.au. 
 (Luke Welling)      -
         RMIT  
,      Tangled Web Design. 
      ( )   - 
         
 "     ".  -
    .      - 
Iuke@tangledweb.com.au. 
  
 (Israel Denis Jr.)      -
 ,      .   
      ,  SAP  
    Web.  1998 .    -
       , 
, . .       Linux, Apache, 
PHP  MySQL;       : 
  (Chris Newman)  -,  
    Internet.      
    MySQL     , 
     .    
    ,    Lightwood 
Consultancy Ltd.      Lightwood Consultancy Ltd. 
   Web-   http://www.lightwood.net,    
   : chris@lightwood.net. 

1   Web-    MySQL 
 
    
      Sams    -
 .  ,        
(Shelley Jonston Markandy),        
   .       
      . 
  ,      MySQL. 
          ,   
   . 
   (Adrian Close)  ,   1998 .  : " 
    ",     (James Woods)   -
  Law        
  . 
, ,        ,  
       .   -
  ,    : , , , 
, , , ,   . 

 
 
     " Web-    MySQL".   
     ,     -
   MySQL       
Web-. 
    : 
       
   ,    
      MySQL     
     4 
     
, . 
      
     Web-,    -
         -
.   ,   ,    -
     (Open Source). 
   ,   ,   ,  
 HTML        -
, , ,     Internet   -
   .      -
 ,        
     .     
      ,    .  , 
   ,      MySQL  -
   Web-.      -
          Web-. 
   ,      ,   -
   .   ,      
  .     ,    -
      .      -
  Web- ,       -
. 
     
  ,    ,  Web-.   
  Web-    HTML,    -
  .    ,   
  HTML, Web-     .   -
,      .    -
      . 

  Web-   MySQL 
  ,  ,    ,  MySQL, -
   :    , -
   . 
  ,    ,     -
  .       -
 ,          MySQL. 
          -
    Web-  ,    -
     MySQL. 
            
   ,      
: 
     
    
    
   Web 
    
  Web- 
   
           -
     .    ,   
        Web--
,  .     ,  
      . 
   ? 
       (  ), -
   Web.  HTML-    ,  -
     .    Web- 
  HTML   ,   . 
     1994 .     
  (Rasmus        
    ,        
,      .   2001 .   -
             . -
 ,       ,   
  http://www.php.net/usage.php. 
        (Open Source).   
    .   ,    -
    . 
     Personal Home Page ( 
 ),          -
    GNU (GNU = Gnu's Not Unix)   -
  Hypertext Preprocessor (  ). 

 
      .   -
    ,  -
  . 
      http://www.php.net 
    Zend  http://www.zend.com. 
    4? 
    ,       -
 4 : 
  4     ,    
  Zend Engine.      
,   http://www.zend.com    Zend 
Zend Cache  Zend Compiler. 
 PHP         Apache. 
           ISAPI 
 Internet Information Server  Microsoft. 
     .     
        
 PHPLib. 
   MySQL? 
(   ,   -
    ().     -
, ,    .  MySQL    
,       , -
          -
    . , MySQL  -
,   SQL (Structured Query Language  
  ),       
   . MySQL     1996 .,    -
   1979   ,      , 
       Linux Journal. 
    MySQL      -
  ,         
. 
      MySQL? 
      ,   
  . 
     Web-,  -
,   Web-,      
    . 
          -
. ,         -
,           
  .. 

  Web-  PHP  MySQL 
        , 
     Web-.    .  
     ,     Microsoft Windows,  
  UNIX      Web-. 
 MySQL    . 
  ,        
   : 
 Linux   Web- Apache 
 Microsoft Windows 2000    Microsoft Internet Information 
Server (IIS) 
   ,    Web-    
,  ,         MySQL. 
   
     Perl, Active Server Pages (ASP)  Microsoft, 
Java Server Pages (JSP)  Allaire Cold Fusion. 
PHP        ,  -
 : 
   
         
       ,   Web 
   
     
  
    
     . 
  .    ,  
    .  ,  
 Zend Technologies (http://www.zend.com),    -
      . 
    
        .  -
  MySQL,         -
 PostgreSQL, mSQL, Oracle, Informix, InterBase  Sybase. 
 Open Database Connectivity Standard (   
   , ODBC),      ,  -
  ODBC-.     Microsoft   
 . 
  
       Web,    
      ,   

 
Web, .     " "  GIF-, -
    ,    ,  
   PDF-       -
  . 
 
   .        
    http://www.php.net. 
  
      ,   -
    Perl.      ,  ,   
C++  Java,       . 
 
         
.         Unix- -
 ,  Linux  FreeBSD,   Unix  Solaris  IRIX  
  Microsoft Windows. 
 ,     -    
   . 
  
      .     -
  ,   -      
,     . 
  ,     -
   ,      
  . 
  MySQL 
  MySQL,  ,  PostgreSQL, Microsoft SQL 
Server  Oracle. 
MySQL   ,     -
,  ,    , -
    . 
     . 
MySQL     .    -
,  -,     
     , 
 MySQL      . 
  
 MySQL         
     ,     , 
      . 

    MySQL 
  
      SQL.      
        - . 
 MySQL   ,      . 
MySQL        UNIX,    
 Microsoft Windows. 
  
    ,   MySQL    . 
    
     . 
  I, " ",      
  .       "" ,   -
 ,       . 
     1, "  ".     
,    .         
   , ,      
. 
  II, " MySQL",     
,         
MySQL,  SQL,    MySQL   -
        MySQL,  
   . 
  III, "    ",  -
   ,        
   .    -
  .   ,     MySQL  -
     ,    . 
  IV, "   ".  -
      .    
   ,        
 .      ,  
 ,   ,       -
 . 
  V, "      MySQL",  -
  ,      ;   -
  ,      MySQL. 
 
 ,           
     MySQL,   ,    . 
   .       -
  Web-,   ,  -
         
,     Web-. 

I 
 
1 
2 
3 
4 
   
   
  
 
   
     
-  

7 
   
       -
  .    -
     .    
    , ASP  -
  ,     
   . 
    ,   
 .     
,       -
   .     
     -
   .     
 .  ,     
     -
 -  ,    -
       , 
     . 
        
  CD-ROM, ,     
      . 
 ,  ,    
  ,       -
   .     -
     . -
       ,  
,        -
 . 
      
,       -
  .     
      
if, else, switch   ?:. 

 1.   
 ,    PHP-    
HTML-,     . 
      : 
    HTML 
    
     
  
 ,   
   
    
  
    
     
  
      
     if, else  switch 
 :  while, do  for 
  
    ,        -
,     Web-    .  -
         
 .      ,  
   . 
      ,     
    .     -
   , "  4  MySQL".   , -
      UNIX  Windows NT,    -
  CD-ROM. 
 : Auto Parts 
         
   HTML-.       -
    Bob's Auto Parts (  ),  
.    ,    ,  
  chapterl  CD-ROM. 
 
     HTML   Auto Parts -
      .     . 
   ,   ,   
  Web.  ,      ,  -
  ,         ,  
    . 

28  1.  PHP 
[is] 
Auto Parts 
Order Form 
Quantify 
Tires 
Oil 
Spark Plugs 
Order I 
 HTML-    
       
    . 
-, ,  
,   PHP-, -
    . 
(    -
 .)     
 ACTION  URL-, -
     -
   (submit). , 
   ,  -
   URL-  -
 ,    
METHOD:  GET ( -
   URL-),  POST ( 
    ). 
-,         tireqty,  
sparkqty.       PHP-.    
   ,      -
.  HTML-       
 field23.    .       
 ,         . 
,       ,    
          .   -
 , ,            
    . 
 1.1  HTML-     . 
 1.1   
   . 
border=0> 
<tr 
<td 
</tr> 
<tr> 
<td size=3 
</tr> 
<tr> 
<td size=3 
</tr> 
<tr> 
<td>Spark Plugs</td> 
<td size=3 
</tr> 
<tr> 
<td 
</tr> 
</form> 

 1.   29 
  
     ,    
ACTION  FORM     -
    .    : 
<head> 
Auto Parts - Order Results</title> 
<body> 
Auto Parts</hl> 
Results</h2> 
</body> 
 ,          
HTML-.        -. 
   HTML 
  <h2>    : 
echo 
       ,      
  Submit ().     -   -
,   . 1.2. 
 ,   PHP-    HTML-. 
    .      : 
<head> 
<title>Bob's Auto Parts - Order Results</title> 
<body> 
<hl>Bob's Auto Parts</hl> 
<h2X3rder Results</h2> 
    PHP- 
 .   ,  
   -
     . 
,     
   HTML,  
      -
 ,   
     
. 
    
   - 
Auto Parts 
Order Results 
Order processed. 
D 
1 
 1.2 ,   PHP-
 echo,    . 

 1.  PHP 
. PHP-     Web-,    JavaScript 
    ,     
  Web-   . 
        : 
 HTML 
   
   
  
        
  
         HTML-. 
 
PHP-       <?   
 ?>.    HTML-,    
   "" (<)    "" (>).  -
  PHP-,    Web-,  
,    PHP-.  ,   -
,    PHP-.      
    HTML-.   
  HTML. 
   .     
 .  -    -
      ,     -
   .     . 
- 
     -.  -
    . 
   
<? echo ?> 
        .   
      . 
         -
  SGML (Standard Generalized Markup Language  -
   ).      
(   ),    
        
     .   
     . 
 XML- 
<?php echo ?> 
       XML (Extensible 
Markup Language    ).   -

 1.   PHP 
   XML-,      -
. 
 
<SCRIPT echo </SCRIPT> 
         ,  
   JavaScript  VBScript.     -
  HTML-,       
 . 
 ASP- 
<% echo %> 
       Active Server Pages (ASP).  
 ,      asp_tags. 
         
 ,   ASP,     -
  ASP. 
PHP- 
,    PHP-,  --
,      .  -
      : 
echo 
  ,  echo     ;  
 ( )      .  . 1.2 ,  
       "Order 
 ,     echo    .  -
    PHP-  ,   -
      . ,     
   Java,        . 
         , -
   .   ,       -
. 
 
 ,     ( ),  -
       .   
   HTML. 
,   ,      HTML-. 
     .     HTML-
: 
<hl>Welcome to Bob's Auto would you like to order 
today? 

32  1.  PHP 
to 
Auto 
would you like 
to order today? 
     ,    
  .   HTML-    , -
     HTML-.     
 .   PHP-  ,   
      . ,  
echo "hello"; 
echo 
echo 
,     . 
 
    ,     :    
   ,   .   -
    ,     -
, ,      ,     
   ..  ,    -
,   . 
PHP-    ,   . 
 ,       -
,     . 
     , C++   
       ,  
   
/* :   
 10  
   
*/ 
      /*   
 */.    ,      . 
       C++: 
echo //    
    : 
echo #    
     ,     (# 
 //)         .  
 ,   ,   

 1.   33 
   
         - ,  
       HTML. 
       -
        -
 .  ,  ,     
      ,   
      .     . 
     .  PHP-   
  : 
echo processed at 
jS F") 
echo 
    PHP- date()    -
      .       
 . ,       
,   . 1.3. 
 
    date().     .  -
   ,      Web-
.      -   
   -    . 
   : 
jS F") 
 ,     ( ) -
   .    ,  , -
.    ,    
  -  -
. 
 
,    
date(),    , -
   .  
      
  .     12-
 , i     
,   , j   -
   , S  
  (   
a F - - ,   
. 
s Auto Parts Order Explo .. 
View 
Auto Parts 
Order Results 
Order processed at 31st January 
 1.3 PHP-  
  . 
2 216 

34  1.  PHP 
(  ,   datc(),    
18.) 
    
          
 .     ,   , -
    . 
 PHP-           
,    ,     .   . 
      
is as 
echo 
echo 
echo bottles of 
echo spark 
         -
  . 1.4.  ,      ,  
  . 
        
. 
  
        PHP-.  -
           ($). 
(        .) 
        . 
             
 .          -
  HTML-.      .   
   ,        
 ,     .     -
, ,     
, ,    
   
    -
      
 ,   -
 $HTTP_POST_VARS  
   -
    -
    .  -
     
 : POST  GET. 
Bob's Auto Parts 
Order Results 
Order processed at 21:09, 9th April 
Your order is as follows: 
2 tires 
1 bottles of oil 
2 plugs 
       
,     
  ,   -
 1.4  ,   
,     
] 

 1,   PHP 
         "On" -
          
 php.ini. 
  ,       
   .      
  "On"  
          
,    .   ,   
   ;       ,   -
  . 
    ,      -
, , Perl,    . 
  ,        -
           . -
      ,    . 
   , ,      , -
   . 
  
   echo    ,  -
     ,      
.      echo,  ,   
         (.), : 
echo $tireqty. 
   ,      
( ).           
  echo.        
echo. 
     
echo 
   .      -
      . 
   
  ,      echo,   -
 .     ()  .     
 .       
  ,    .   -
, .. ,     .   -
, tires"   .   ,  . 
  ,      .    
 ?        , -
  . 
,            -
 .     ,    -
,    ,   . ,  
  ,     . 

36  1.  PHP 
 
    . (     -
 ;        5  6.) 
    : 
         , , -
    .     -
     .   
    " ". 
      . 
      .    
 .       
       . -
      PHP-    -
    . 
        . 
    ,     -
.    ,     
  . 
  
   ,   HTML-,    
   . 
      ,     
 ,     .     
   ;       . 
   
       =.  
           
.        .    -
  . 
      -: 
$totalqty =  
= 
          -
 .       , 
: 
$totalqty = 0; 
= 
  
        . 

 1.   PHP 
  
    : 
 Integer ()      
 Double ( )      
 String ()      
 Array ()        -
  (.  3) 
 Object ()       (.  6) 
    pdfdoc       -
 PDF (Portable Document Format    ). -
 PDF      29. 
  
       .    -
       ,    -
   ,    ,    
  .        . 
,        
   : 
$totalqty = 0; 
= 
      0,  
   integer. ,    double. 
  ,         : 
= "Hello"; 
       string. PHP    
       ,   . 
    " "   -
 . ,   ""   ,  
 .          
 . 
  
  ,  ,     
  .    ,    .    
 ,    ,     
 . 
,          -
  . 
= 
   " ,    -
    double     -

38  1.  PHP 
   double.     , -
    integer. 
  
       ..  . -
      . 
( ,            
   ,       
,       .) 
        -
    .     
= 
    , : 
= 
    ,       
 .         
 ,        -
   . ,   ,   , 
  for. 
 
   , ,   ,  . 
 ,    .   ,  
 ,          
  . 
           
   .       
define: 
10) 
4) 
     . 
   ,      .  
          -
  .     ,   ,  
,        . 
     ,     -
    . 
        ,  -
         .   
  ,    . ,   
       : 
echo TIREPRICE; 

 1.   PHP  
  ,  ,    
  .     ,  
 phpinfo(): 
        PHP, a 
   .       
   . 
   
   (scope)    ,   
 ()  .      -
   : 
  ,   ,    ,  
  . 
 ,   ,    -
 . 
 ,   ,    -
,        . 
        -
.   ,        
. 
  
    ,      
       .    
          . 
    :   (=)   -
  (.)       . 
       ,    -
,        . , 
      ,    -
 =,  ,  .    , .. 
,     . 
i 
  
        . 
   . 
 1.1    
  
+  $ + $ 
 $ - $ 
*  $ * $ 
/  $ / $ 
%   $ % $ 

 1.  PHP 
         , 
: 
$result = $ + 
    ,   .    
, ,    ,    $ 
 
          (.. -
,    ,  )    
. , 
$ = -1; 
      .    -
        -
     . 
        Sa  -
    : 
$ = 
$ = 
$result = 
,    Sresult,     -
 27  10, .. 7.   ,    -
         .   -
         ,    
.          
.        .  -
            ; 
    ,    . 
  
       .  -
            
          
 . 
$ = 
$ = "Auto Parts"; 
$result = 
    Auto Parts". 
  
     =,   .   
       " ". -
, 
= 

 1.   
     "   
 ".        
   . 
    
       , 
    .   
$ + $ 
        $  -
,   
$ = 
     0. 
     : 
$ = 6 + ($ = 
      11.   
   :      
,   . 
         -
 ,      .    
 ,    . 
   
       -
 .         -
-         . 
 
$ += 5; 
   
$ = $ + 
        
     . 
         -
  . 
 1.2    
  
$ += $ $ = $ + $ 
$ -= $ $ = $ - $ 
$ $ $ = $ $ 
$ /= $ = 
$ $ $ $ % $ 
$.= $ $ = $ . $ 

42  1.  PHP 
     
     (++)   -
  +=  -=,    . 
         -
 .   : 
$=4 
echo 
      ,   
,   ++   $.     $ -
  1,     .    -
 $   5,   5   .   -
   5. ( ,   ,   
 $, :      -
    $ + 1.) 
,   ++   $,   -
 ,     .   -
: 
$=4 
echo $a++ 
       .  ,  -
 $   ,     1.    
  4.      .   -
     $  5. 
 ,     ,   -
 $   1,   . 
 
   4    & (),   -
     . ,   -
  ,    ,   
-  . , 
$ = 
$ = 
       $      
   $ ,   : 
$ = 7; //  $ -  5 
   ,    &, : 
$ = 
$ = 
$ = 7; //   $  $  7 

 1.    43 
  
      . ,  
   ,      -
   true ()  false (). 
  
  == (  )     
. ,  
$ == $ 
      ,   -
 $  $.       ,  false,  
  . 
      .      
  ,        .    
    true,     false. , 
      : 
$ = 
$ = 7; 
    $ =    true. ? 
     $ =  ,  -
 ,      7.    ,  
   true.       -
  $ == $,     false, ,    
 ,    .     
      . 
     , , ,    
.   ! 
   
      ,    
. 1.3. 
 1.3   
   
 $ == $ 
 $ === $ 
!=   $ != $ 
   $  $ 
<  $ < $ 
> $ > $ 
<=    $ <= $ 
>=    $ >= $ 

44  1.  PHP 
     ,    4, 
   true    ,      
     . 
  
       -
. ,    ,    $ -
    0  100.        $ >=0 
 $ <= 100,   AND (),    : 
$ >= 0 && $ 
    AND (), OR (), XOR ( 
)  NOT (HE). 
         . 1.4. 
 1.4   
&& 
and 
 
 
 
 
 
 
 
$ && $ 
$ $ 
$ or $ 
 
 true,   $  
false,   
 true,    $ 
 $   true;   
  
 true,    
 $  $    
 true;   false 
  ,   &&,    
 
  ,   ||,    
 
 and     ,   &&  ||. -
       . 
  
       -
   . 
,         ,   
,     . 1.5. 

 1.   45 
 1.5    
 
  
&   $ & $ 
  $ | $ 
  
 $ * $ 
  
  $ $ 
  $ $ 
,    
 $  $,  
    
,    
  $  
   
   
,    
 $,   
  ,  
 
,    
  $  $,     
,   
    
   $  
  $  
   $  
  $  
  
 ,     . 
  (,)       
  .      . 
   new  -> , ,   
       .    
   6. 
    []      
     3. 
   ,      . 
  
 , ?:,    ,   .     
? ,   ,    
        
   . 
   : 
($grade > 50 ? "" : " 
        
""  " ". 
   
   @     , 
..  ,     . 

46  1.  PHP 
, 
$ = 
   @       
  (  ).    @    
 . 
          
        .   
    track_errors,     
    
    
        -
            -
         ,   -
 ~ (). 
,     ,    
  ,     .    
 . 
,   UNIX-     
$out = 
  Windows     
$out = ' 
echo 
            -
            
. 
       .   -
   16. 
 :     
,   ,    ,   
        . 
          : 
$totalqty = $tireqty + $oilqty + 
= $tireqty * TIREPRICE + $oilqty * 
+ $sparkqty * 
= 
echo 
echo "Items ordered: 
echo "Subtotal: 
$taxrate //     10% 
= * (1 + 
= 2) 
echo "Total including tax: 
           
1.5. 

 1.   47 
 ,     -
  .  -
 (+)   (*)  
   ,  -
   (.)   -
    . 
 ,    
  
       -
 .      
   . 
   -
    , 
      -
 . ,  -
 : 
= $tireqty * 
+ * OILPRICE 
+ * 
Auto Parts 
Order Results 
Order processed at April 
Your order is as 
1 
1 oil 
1 spark plugs 
Items ordered: 3 
Subtotal: 14.00 
including tax: 
 1,5     
    
. 
  ,      ? 
   , ..   . 
  :   
     ,    . 
 ,   ,   -
    .      -
  ,  ,       . 
        . 1.6. 
 1.6    
  
  
  
  
  
  
  
  
  
  
  
  
  
or 
and 
prinf 
= += -= = /= .= &= |= 
II 
&& 

48  1.  PHP 
  < <= > >= 
  
  . 
  * / % 
  ! ~ (int) (double) (string) (array) (object) @ 
  [] 
  new 
  () 
   ,    ,   -
 ,     . 
 ,     ,   
  :    .    -
    .        
   . 
     : 
= * (1 + 
    
= * 1 
  ,        -
 ,   ,      . 
  ,  ,    -
 1 + 
         
.      ,    -
 . 
     
      ,    
    .   ,   
     . 
     
       . 
        -
 ,      . 
string 
int var, string 
      .  -
     ,     "unknown type", 
        : integer, string, 
array  object. 

 1.    
      ,   
 ,  ,       
 . 
     : 
$ = 56; 
echo 
($a, 
echo 
     $   integer.  
      double. 
      .     
         false.  
 : 
 
 is_double(), (     ) 
 is_long(), is_integer() (     ) 
 
 
   
   ,     -
. 
      : 
int 
          -
 true,   ,  false   . 
  ,      
 : 
int 
       true. 
 ,       
    ,  , , ,  
 false.     : 
int 
     . 
       : 
echo 
echo 
echo 
echo 
 ,   . 

 1.  PHP 
 isset()      true  -
  ,       .   
 empty()    . 
  ,     isset()  -
  false,    
         
  . 
  
  ,   ,   
.     : 
int 
double 
string 
          -
 ,   . 
  
     ,    
    .      -
 (  )   ,  .  -
       . 
      
       , 
      . ,   
    ,   . 
 if 
     if.   ,  -
 .     true,   -
    .    if      
,         ,    , 
 , ,       Submit.  -
 "Order processed" (" "),      -
  . 
     , ,    
 "You did not order anything on previous page!" ("     
        if: 
$totalqty == 0 ) 
echo "You did not order anything on previous 
     == 0. ,   -
 (==)   ,    (=). 
 0    true,    
 .      ,  

 1.   PHP \ 
  false.     true,  echo -
  
    ,  if,     
.           if. 
       .  -
       : 
$totalqty == 0 ) 
{ 
echo 
echo "You did not order anything on the previous 
echo 
} 
   ,    ,  . -
    true,    .   -
      . 
:      
  ,       .  -
    .  ,    , 
     ,       -
,           
 .     ,   
   if,  ,  ,    . 
 else 
           -
,          . 
 else    ,   -
,      if  false.   
   ,     .   
,    ,      
. 
         else,    
,   . 
$totalqty = 0 ) 
{ 
echo "You did not order anything on the previous 
> 
else 
{ 
echo 
echo bottles of 
echo spark 
} 
  if   ,      
.        , 
   == 0  true,      -
       . 

52  1.  PHP 
$totalqty 0) 
{ 
echo "You did not order anything on the previous 
} 
else 
{ 
if ( $tireqty>0 ) 
echo 
if ( $oilqty>0 ) 
echo bottles of 
if ( ) 
echo spark 
} 
 elseif 
        . 
       -
 elseif,      else  if.   
          ,  
  ,    
       .  
   : 
   10     
  10-49    5% 
  50-99    10% 
  100      15% 
          -
 if  elseif.          (&&). 
$tireqty < 10 ) 
$discount 
( $tireqty >= 10 &S $tireqty <= 49 ) 
$discount = 
( $tireqty >= 50 SS $tireqty <= 99 ) 
$discount = 
$tireqty > 100 ) 
$discount = 
 ,     elseif,   else if    
. 
     elseif  ,  -
      .      , 
          
     .      ,  -
     ,     
 ,     . 
 switch 
 switch    if,    -
       .   if   
  false.   switch      

 1.    53 
    ,    
  (integer, string  double).  -
   ,   -
 ,   -
 case,   ()  
      
 ,     
  case. 
  ,    
    .  
      . 
    HTML-, 
     ,  -
  . 1.6: 
fiettesb Home 
Bob's Auto Parts 
Order Form 
Quantity 
Oil 
Spark Plugs 
How did you find Bob's 
 1.6    
   ,  
    Bob's Auto Parts. 
<tr> 
<td>How did you find 
<tdxselect 
<option value = a regular customer 
<option value = advertising 
<option value = directory 
<option value = of mouth 
</select> 
</td> 
</tr> 
 HTML-    ,   
 "", ""  "d".         -
   if  elseif: 
== "a") 
echo 
== 
echo referred by TV 
== "c") 
echo referred by phone 
== "d") 
echo referred by word of 
       switch: 
case "a" : 
echo 
case : 
echo referred by TV 
case "c" : 
echo referred by phone 
case "c" : 
echo referred by word of 
default : 
echo do not know how this customer 
break; 

54   PHP 
  switch   -
 ,   if  
elseif.  if   
   ,   
    
    . 
 switch  -. 
  case   switch 
,  -
   ,    -
 break.    switch 
   ,   
 case,   
 .   -
 break    
,    switch. 
php Microsoft  
' Edit 
I . . 
Distance Cost 
50 5 
100 10 
150 15 
200 20 
250 25 
'i 
 1.7     
    . 
  
 ,     ,    " 
   
      .     
else, elseif  switch     ,     -
     if.      -
    ,    . -
        . 
:   
  ,         -
  .  -   
 ,        . 
  ,   ,   -
    .         
    . 
     . 1.7. 
HTML-,   ,    1.3.  ,  
 ,     . 
 1.3  HTML-        
<body> 
<table 
<tr> 
<td 
<td 
</tr> 
<tr> 
<td 
<td 
</tr> 
border = 0 cellpadding = 3> 
bgcolor = align = 
bgcolor = align = center>Cost</td> 
align = right>50</td> 
align = right>5</td> 

 1.   55 
<tr> 
<td align 
<td align 
</tr> 
<tr> 
<td align 
<td align 
</tr> 
<tr> 
<td align 
<td align 
</tr> 
<tr> 
<td align 
<td align 
</tr> 
</body> 
right>100</td> 
right>10</td> 
right>20</td> 
right>25</td> 
     HTML- ,   -
     ,   ,    -
 ,   ,      . 
        
   . 
 while 
       while.   if,   
   .    while   if   
,       if    
     .  while     
  ,     true. 
    while ,   ,   -
   .      -
,      for. 
   while   
 ) 
  while    1  5. 
= 
while <= 5 ) 
{ 
echo 
     .     false, 
      .    , 
  . 
 while     -  , -
      ,   . 
1.7. 
  1.4  while      . 

56  1.  PHP 
 1.4         
  
<bodyx 
<table border = 0 = 3> 
<tr> 
<td bgcolor = align = 
<td bgcolor = align = 
</tr> 
<? 
$distance = 
while ($distance <= 250 ) 
{ 
echo <td align = 
echo <td align = $distance / 10 
$distance += 50; 
?> 
 for 
     while  . -
    .     
   .       -
. 
           -
. 
   for   
      .    -
   . 
     .   -
  false,  .      
   . 
     .     
 . 
      .    
        . 
  while,    1.4,    -
  for. PHP-   : 
<? 
= 50; $distance <= 250; $distance += 50) 
{ 
echo <td align = 
echo <td align = $distance / 10 

 1.   PHP 
    while  for .   for -
       . 
               
.      ,    -
. 
 ,        for  
      . , 
         ..  -
   : 
for <= $i++) 
{ 
$temp= 
echo //  
} 
   ,       
 . 
 
  ,   ,   . -
     
do 
 do..while    while ,       . 
 ,          -
    . 
   ,         false  
     true,    ,   -
     . 
= 100; 
do 
echo 
} 
while < 1 ) 

58  1.  PHP 
      
   ,   ,     
      . 
    ,    
break,      ,   switch.  -
  break      ,   
 ,   . 
      ,   -
 continue. 
     PHP-,   
 exit.        . , 
        : 
$totalqty = 0 > 
{ 
echo "You did not anything on the previous 
exit; 
} 
  exit     PHP-. 
 :    
  ,      .   
    ,      
  . 

  
  
      - 
 ,   HTML-, -
       -
  .   , 
  ,    , 
     .  
      -
    ,     
  . 
    ,    -
       
       .   -
,       . 
      -
    ,  
MySQL. 
      
: 
      -
 
   
       
   
    
   
   
     
    :  -
   
   

60  1.  PHP 
      
     :   () -
    . 
     ,      -
 (flat)      .    
      ,      
. 
    ,   ,      . 
        , , 
   . ,     
 ,         
. 
            -
     .         
    UNIX,      
. 
       
        , -
     .        -, 
    . 
    HTML-  PHP-      
 CD-ROM. 
  ,       (. . 2.1). 
 ,     ,   address.  
   ,         
    ,      
. ,          
 (.  1). 
          .  -
 Web-,       -
 . 
 2.1 
    
   
Bob's Auto Parts 
Order Form 
Tires 
Plugs 
Smith 

 2.     
   
       : 
1.  .     ,   . 
2.    . 
3.  . 
,          : 
1.  .       (,   -
),          
  . 
2.    . 
3.  . 
       ,   
     .       
 . 
     . 
  
          -
  ,    .    
. 
  
    ,      
.   ,         -
   ,    ,       
  .  ,     
        , -
     ,      -
       . 
      : 
1.      ,        -
. 
2.          -
         . 
3.        ,    
  ,     . 
 fopen()        -
. 
     
 ,         . 
         : 
$fp = 

62  1.  PHP 
      .    
,       . 
    ,   .   
    ,         - 
   orders.     
$DOCUMENT_ROOT PHP.       -
 Web-.  ,     "-
        -
    . ,      
 Web    .    -
,         
$DOCUMENT_ROOT. 
              
(/   UNIX ,  , :\   Windows).   UNIX, -
  ,     , -
    ,        -
 ,   ,     .   
       ,     
    ,     -
 " "   . 
    ,         
,     .     
    -     . 
  UNIX        ( -
 )   (/).   Windows    
    .       
     (.. ),   fopen -
   .       -
     ,     -
: 
$fp = "w") 
      ,    -
 .   ,     .    
    "w"       . 
    . 
 2,1     fopen 
  
      ,    . 
        ,    . 
w       ,    .  
  ,   .    , 
        . 
        ,    . 
   ,   .    
,         
. 

 2.     
  
        (),  
   ,   .    
,         
. 
+        ()  , 
    ,   .    
,         
. 
b           . 
   ,      
  .   Windows   ,  
UNIX - . 
 ,      , -
  ,    .     
   .         
  . ,    ,    -
 : 
$fp = 
   fopen()   .   -
,       (  -
 ; .  ).   ,    1.   
       : 
$fp = , 
      fopen()     
    ,       -
    ,        -
   
   FTP  HTTP 
  fopen(),         
 ,       FTP  HTTP. 
      ftp://,   
          . 
       HTTP- 
         .   -
  HTTP       -
   ,     : 
  
     (   ) Web-,  
,    HTTP     
 (  ).     . 

64  1.  PHP 
 fopen()   -
 HTTP,   
 URL- ( 
 ),    
    -
 . 
,     URL-
    ,   
   . 
Auto Parts 
Order Results 
Order a! April 
is as 
4 spark 
Total order is 16.00 
to to is ZOO 
-
in on line 54 
 2.2 PHP ,   
   . 
 
  
 ,   -
     ,  
      
.      -
  (. . 2.2). 
        ,  
,  ,     ,  
  .    ,   -
 ,      Web-   -
 ,    . 
        Web-. 
      UNIX   -
          ,  
 : 
777 
  ,  ,       -
,  .      ,  -
     Web.     orders -
         
   
     ,    
    ,     .    
  ,     ,     
    . 
    fopen()  ,   
 false.        , -
         : 
@ = "a", 1) 
if (!$fp) 
{ 
echo Your order could not be processed at this time. 
try again 
exit; 

 2.     65 
Bob's Auto Parts 
Order Results 
Order processed at 16:41, April 
Your order is as follows: 
4 spark 
Total of order is 16.00 
to ship to is 200 Intercity 
order not be processed this time. Please 
 2.3    
   ,  , 
     . 
 @    
 fopen()    
   -
  ,  
  .   
 ,  - -
 ,    -
     -
    . 
 ,   @ 
     
.    
    23. 
 if   
$fp   , -
    fopen  
 ,   , -
     -
  . -
    ,      
 </html>,    HTML-. 
,       , -
  . 2.3. 
  
       .    -
    (file write    )  fputs() (file put 
string     );      
   : 
fwrite($fp, 
          
,  $fp.    ,   -
     
  
     ,     
  .      
int fp, string str, int 
  length     ,  
 .        
 str  ,   fp,        
 length ,    ,   . 
  
   ,     , 
      . (,  -
3 216 

66  1.  PHP 
      , ,   
    .) 
  ,       .  
   : 
= tires 
spark 
           . 
   ,       
    .     -
,       
         ,    -
     . -,   -
 ,       
      . 
,  ,    ,  -
      ,     
          -
.      4.  ,  -
        .   
         HTML -
,     . 
        
    .     
  3  4.        . 
         
,    2.1. 
 2.1 orders.txt      
15:42, 20th April 4 tires 
$434.00 
22 Short St, Smalltown 
15:43, 20th April 1 tires 
$100.00 
33 Main Rd, Newtown 
15:43, 20th April 0 tires 
$26.00 
127 Acacia St, 
1 oil 6 spark plugs 
0 oil 0 spark plugs 
1 oil 4 spark plugs 
  
          
fclose(),   : 
    true       false, 
    .      ,   
 ,         -
. 

 2.     67 
  
           
      ,     
. 
  Web-,      
  .       2.2. 
 2.2       
Auto Parts - Customer 
<hl>Bob's Auto Parts</hl> 
<h2>Customer Orders</h2> 
@ $fp = 
/ 
if (!$fp) 
echo orders 
try again later 
while 
$order= 
echo 
</body> 
       : -
 ,   ,  . ,   -
         . 2.4. 
 2.4 
 vieworders.php 
   
  , 
   
   
php 
, 
Help ... . . .. . 
Auto Parts 
Customer Orders 
15:42, 20th April 4 tires 1 oil 6 spark plugs 22 Short 
15:43, 20th April 1 tires 0 oil 0 $100.00 33 Main 
15:43, 20th April 0 tires 1 oil 4 spark plugs $26.00 127 Acacia St, Springfield 

68  1.  PHP 
   ,    . 
   : 
  ,       fopen().     
   ,     "": 
$fp = 
  : feof() 
     while       ,  
    .        
  feof(): 
while 
 feof()      .   
  true,       .  -
  ,  ,  feof  File End Of File (:  -
). 
   (   )      
 ,     EOF. 
 : fgetss()  
         
$order= fgets($fp, 
            . 
        ,    -
   EOF       99 .  
        . 
   ,      
.      ,   , 
    . 
   fgets()   fgetss(),  -
 : 
string fgetss(int fp, int length, string 
        ,   
       HTML,   .   
    ,      
  fgetss()     -
   ,  -    , 
 .       HTML- 
      .  
     PHP-    
      . 
     fgets().    -
: 
array fgetcsv(int fp, int length, string 

 2.     
          -
   ,   ,  , -
        .  -
       ,      
,     fgetcsv().     
fgets(),     ,    . 
, 
$order = fgetcsv($fp, 100 
            
(\t).      (     -
     3. 
 length         
,   . 
  : file() 
             
.    . 
        -
    : 
  ,       
( ),    .      
int (string int 
   ,        
   ,    fopen().   -
  ,   . 
-,      
    fopen().        
fpassthru(),    ,   ,  -
,   .       . 
       
: 
$fp = 
       
,  false    . 
         
     ,    
        .    
     3.  ,   , ,   
    : 
$filearray = 
        ,  -
       . 

/  1.  
 : 
           -
.      fgetc().     
         . 
 while       ,   
  
< 
$char = 
if 
? 
} 
  fgetc(),           
          .  -
        -
   \ HTML-      -
   .        
 ,         . (  
  ,  .)      -
 . 
      fgets() -
  ,      EOF,     fgets()  -
 .          
   EOF      . 
           -
,    -      -
. 
   : 
    ,      
 fread()       .  -
   : 
string fp, int 
        ,    
,   . 
    
    ,     
. 
  : file_exists() 
         , 
   file_exists(),     : 
if 
echo "There are orders waiting to be 
else 
echo "There are currently no 

 2.     71 
  
       fflesize().    
,   : 
       fread()  -
    (   ).   -
    : 
$fp = 
fread( $fp, 
$fp ) 
  
       ,   
   un!ink(). (      delete.) : 
    false,      .  -
,             
  . 
  : fseek  ftell() 
            
  ftell(). 
      .  
ftellQ        . ,  
    (    
 : 
echo "Final position of the pointer is (ftell 
echo 
echo "After rewind, the position is 
echo 
         . 2.5. 
 2.5 
  
   
 ,  , 
 234 .   
  rewind  
    
   . 
Auto Parts 
Customer Orders 
15:42, 20th April 4 tires 1 oil 6 spark plugs S434.00 22 Short St. Smalltown 
15:43, 20th April 1 tires 0 oil 0 sparkplugs $100.00 33 
15:43, 20th April 0 tires 1 oil 4 sparkplugs $26.00 127 Springfield 
Final of the pointer is 234 
position is 0 

72  1.  PHP 
 fseek()         
  .     
int fp, int 
    fseek()      
,   offset    .   
   fseek()  ,  . -
,  fseek()          
   . ,      
     ,     
. 
  
  ,       
. (      ,   Web- -
    .)  ,   
     ,      -
  fopen()     ?     
 ?      ,   ,  -
?       ?     -
    ,     -
?          
,       . 
      .   -
     flock().     -
  ,           . 
   : 
(int fp , int 
         , -
   .    true,  -
   ,  false    . 
   operation   . 2.2. 
 2.2   operation  flock() 
 
\  .  ,     
    . 
2  .   .     
 . 
3   . 
+4  4     operation  
       . 

 2.     / 
         , 
    ;       
. 
       
processorder.php    : 
$fp = "a", 1) 
//     
fwrite($fp, 
//    
      
$fp = 
//     
//   
//   
   ,     .  ,   -
    ?     -
,      ,   , -
    , ,   ,     . 
    ,  . 
  :   
  
         .  
      MySQL   -
   .     : " 
 ?" 
     
       : 
     ,     -
. 
          . 
  ,        
-          -
 .    ,  -
  (,   ,   ), 
        . 
     .   ,  
 ,         
 .  ,      "-
 "  .       -
        
,       .    
 ,     -   . 

74  1.  PHP 
           
  ..          
.           (.. 
   ),    -
    ,      ,  -
     .       
      . 
  ,     ,   -
       . 
       
     ()    -
: 
        ,   -
. A MySQL,    ,    , 
         
. 
          , -
  . 
       -
,       . 
      . 
       . MySQL -
      . 
,        
,   (,   , )  , 
    ,    . ,  
     PHP-,     -
 ? 
  II, " MySQL",      -
    , ,  ,     MySQL  -
 Web-,     . 
  
         -
      16.      -
  ,     ;     -
  ,      . 
 ,       , -
  ,     http://www.php.net. 
  
    ,        -
      

 
 
     -
   . , -
   ,  ,  
   .    -
,    ,  -
, .      -
.      
,     ,   . 
,    ,  
 . 
   ,  
  . ,    
 -  , , -
   ,   
      Perl, , -
 ,      
.    -
 ,     -
,  .     -
        
 . 
      -
 ,  ,   -
     ,  -
 .  ,   
        
    , -
   . 
      -
: 
   ? 
    
   

76  1.  PHP 
   
   
   
   
  1   .     -
  ,    ;  ,    
  ,     ,   -
   . 
 ,   ,    . 
 . 3.1      ,    ,  -
     . (   -
  .) 
Tires Oil Spark Plugs 
 
 3.1 ,   ,    . 
 ,      ,     
  .   ,     
 ,          . 
       .  ,  -
          . , 
     .      
    PHP- 
      .   
      (  ),  -
    . 
       , -
,  ,     .     
 . 
  ,     ,  -
     Perl.      -
     , ,  ,  
 . 
     . 
   
    
  ,   . 3.1,    
 : 
= "Tires", "Oil", "Spark Plugs" 
    products,    : "Tires", 
"Oil"  "Spark Plugs".  ,    echo,  -
    ,  . 

 3.   / / 
     , ,    -
 ,     . 
  ,     ,   -
        
       ,  
        
   numbers,  ,     1 
 10: 
= 
      ,    -
   .       "-
   "   . 
      ,    -
    .      10. 
          
     .     
    "   "  . 
    
       .   -
 ,          
,  . ,  , ,    -
 .       . 
,     products,   
Sproducts[0],  $products[2]. 
     .     -
  , C++, Java     ,   -
  ,   . 
     ,      
  =.        "Tires" 
 "Fuses". 
] 
        
echo 
   ,      -
 .      . 
      
= 
= "Oil"; 
= "Spark Plugs"; 
    ,       
  .      . 

78  1. PHP 
      
     ,   
      for: 
for ( $i = $i++ ) 
echo 
     ,    ,    -
          
 .         -
      .  -
       ,     
   . 
  
         -
  ,   .  ,   -
   0 ,  --1  ..    
 .        -
  ,  . 
   
    ,     -
   ,       . 
$prices = "Spark 
    
  ,         , 
  ,    prices     
"Tires" ],  "Spark Plugs" ]. 
   ,    -
     . 
           
        ,    
    . 
$prices = 
= 10; 
= 4 
   ,    ,  -
   .        .  
      . 
= 100; 
= 10; 

 3.   79 
  
  
    -
   ,    
    -
      -
   
$element = $prices ) ) 
echo "key" 
echo -
echo $element[ "value" ] 
echo 
Tires - 100 
Oil 
Spark Plugs - 4 
 3.2  each  
     
. 
,    ,   . 3.2. 
  1    while   echo.    -
       .   
        .  
 each()    while,       
         . 
      .    
         -
 .  key  0    ,   value  1  -
  .      ,   -
 ,   . 
           -
      .  ,  -
 each(),    : 
$list( $price ) = $prices ) 
    each()      -
          . 
 ,  list()     0  1 -
,   each(),    :  
       , -
   . 
while ( $price ) = $prices ) ) 
echo -
     ,   ,    , 
  list()    . 
    ,    -
 .           
,    reset()      
  .       prices -
 : 
while $price ) 
echo - 
$prices ) ) 

80  1. PHP 
     -
    ,  -
     . 
  
     -
       
     -
.  ,   -
 .    -
    ,  , 
     -
  . 
TIR 
OIL 
SPK 
Tires 
Oil 
Spark Plugs 
100 
10 
4 
 
 3.3   
  ,  
 ,    
 . 
    ,   ,   
   ,        
. 
 . 3.3 ,   ,     
,       ,   -
    . 
    ,   . 3.3,    -
  -: 
= "Tires", 100 
"OIL", "Oil", 10 
"SPK", "Spark Plugs", 4 ) ) 
   ,       . 
,           -
   .          
 ,          . (-
      0,        -
 0.) 
          
      : 
echo 
echo 
echo 
            for 
   for. 
for ( $row = 0; $row < 3; $row++ ) 
for ( = 0; < 3; ) 
{ 
echo 
echo 
         : 

 3.   
        , 
          -
 . 
,        ,  -
  . 33.      .   
       ,   . 3.3, 
  : 
= Code => 
Description => "Tires", 
price => 100 
) , 
Code => 
Description => "Oil", 
price => 10 
), 
Code => 
Description => "Spark Plugs", 
price 
    ,     . -
 ,      Description (),    
   1.    ,   -
,      [][].    , -
        . 
        for  
   .        -
  : 
for ( $row = 0; < 3; $row++ ) 
{ 
echo 
} 
       -
        -
.    list()   while,   -
 . ,   for   while. 
for ( $row = 0; $row < $row++ ) 
( 
while ( $key, $value ) = $products[ $row ] ) 
echo 
} 
echo 
! 
He       ,   -
    ,  ,   ,   
 . 

82  1.  PHP 
   , -
  .     
    ,  
  ,    
 .     -
      
,   . 
      
  ,    -
     . 
,   , -
   ,   
. 3.4. 
     -
,      , 
  . 
Truck Parts 
Description Price 
Parts 
Code 
Code 
Tires 
Oil 
Spark Plugs 
10 
  
 3.4    
    . 
$categories = array( array (array( "Tires", 100 ), 
"OIL", "Oil", 10 
"SPK", "Spark Plugs", 4 
array 100 
"OIL", "Oil", 10 
"Spark 4 
array "Tires", 100 ), 
"Oil", 10 
"Spark 4 
      ,    -
     
for $layer = 0; $layer < 3; $layer++ ) 
echo "Layer 
for ( $row = 0; $row < 3; $row++ ) 
{ 
for ( = 0; < 3; ) 
{ 
echo | . 
} 
echo 
       
 .         
 ,      ,  
  .      -
     . 

 3.    
  
    ,   . -
    . 
  sort() 
        : 
= "Tires", "Oil", "Spark Plugs" 
       : Spark 
Plugs, Tires. 
      .   , 
   ,   ,     
     : 
$prices = 10, 
      4, 10, 100. 
 ,   sort   , ..   -
  . ,    
  asort()     
 
           
,     ,   
     . 
    ,     -
   ,        . 
$prices = array{ "Spark 
       .  
     ,     .  -
     ,   ,    
     ,   .   
         Oil, Spark Plugs, 
Tires. 
$prices = "Spark 
    
        -
    .       
,      .  
   
       ,   -
.      -

84  1.  PHP 
    .    -
       .  
       -
   . 
   
 ,    ,   , -
    ,  .     
      ,      
  .       
      .     
            -
  . 
   
      .   
   ,   ,    . 
= "Tires", 100 
"OIL", "Oil", 10 
"Spark 4 ) ) 
   ,      ? -
 ,     , ,  -
 ,    .      
        .  ,    
,     usort()   ,   -
 .       . 
          
    . 
function $y) 
{ 
if ( $[1] == ) 
return 
if ( $x[l] < $[1] ) 
return 
return 
} 
      PHP-.    -
     .     
   5,        . 
      function.   
 .     ,    -
 ().    ,  .  -
 ()   :   .      -
    . 

 3.   
          -
   ,       . 
    Description  ,   $[1], -
 Description      ,     
.    Description  ,   , -
  $[1]  $[1]. 
    ,      
 .    .      -
   return. ,  return 1;   
1 ,  . 
     usort(),  compare()  
   .    0,      , -
 ,   ,      .  -
     ,      1  -1. 
      ,  
        -
 
 ,       ,   
   .      -
         : 
function $y) 
{ 
if ( $[2] == $[2] ) 
return 
else if ( $x[2] < $[2] ) 
return 
else 
} 
   compare)     -
  . 
 ""    "user" (""),   
     .   
      -
  . 
  asort(),     -
    .   ,  
     .      
 ,   ,      
  uasortQ. 
       
   .   ,  -
     .      
 ,   ,      
  
       
 sort(), asort()  ksort()      
 ,       

86  1.  PHP 
     ,    -
      .    -
 ,    ,   
 .        
,      1,    ,  -1,  
  . , 
function $y) 
{ 
if ( $[2] == $[2] ) 
return 0; 
else if ( $[2] < $[2] ) 
return 
else 
return -1; 
) 
   reverseCompare)     
    . 
     
       -
    .    
   .    ,  
      . 
  
 ,         -
    .     -
 ,    ,       
  .     , ,  
        .    
,        . , -
         , -
     ,       . 
 3.1 bobs_front_page.php       
   Bob's Auto Parts 
<? 
$pictures = 
?> 
<head> 
<title>Bob's Auto Parts</title> 
</head> 
<body> 
<center> 
Auto Parts</Hl> 
<table width = 100%> 
<tr> 

 3.   87 
for $i = 0; $i < 3; $i++ ) 
echo align = 
echo 
echo width = 100 height = 
</tr> 
</center> 
</body> 
    ,    
     ,    . 3.5. 
  
      , -
     . ,   -
  ,  ,    
  10  
       , 
          
        ,   for: 
= 
       ,  
   .    ,    
    --     . 
      ,       -
        . -
 ,       
         . 
 3.5 
 
  
  
  
!  
Address 
Auto Parts 
 

 1.  PHP 
       
  ,   
= 
= 
 ,     
 .     ,     
 . 
    
  2     .     -
 : 
15:42, 20th April 4 tires 1 oil 6 spark plugs $434.00 22 Short St, Smalltown 
           -
  . ,    3.2,    . 
 3.2 vieworders.php       _ 
$orders= 
= 
if 0) 
{ 
echo orders pending. 
Please try again later 
} 
for $i++) 
< 
echo 
      ,     . 2.4, -
   2.2   .     -
       .    -
   . 
      count()    
  . 
 ,           -
 ,         -
    .     , -
   3.3. 
 3.3 vieworders2.php     ,  
     _ 
<head> 
Auto Parts - Customer Orders</title> 
<body> 
s Auto Parts</hl> 
Orders</h2> 

 3.   89 
  
   
//    
= 
if == 0) 
{ 
echo orders pending. 
Please try again later 
echo 
echo bgcolor = V 
<th bgcolor = 
bgcolor = 
bgcolor = 
<th bgcolor = 
bgcolor = 
of orders; 
Plugs</td> 
for 
{ 
 
$line = explode( $orders[$i] 
   
$line[l] = $line[l] 
= 
$line[3] = $line[3] 
 
echo 
<td align = 
<td align = 
<td align = 
<td align = 
echo 
</body> 
,    3.3,     ,   -
  ,    3.2,     explode() 
   ,        -
   . 
      . 3.6. 
 3.6 
   
   
 explode  
  
   
   
  
. 
Bob's Auto Parts 
Customer Orders 
! Order 
20th April 
20lh April 
April 
1 0: 
..... . 
6 Short SI, 1 
33 Main I 
4; 127 

 1.  
 explode   : 
array string ) 
           -
  ,     
) 
      .   -
    . ,  
20th April\t4 tires\tl oil\t6 spark Short St, 
Small 
   "15:42, 20th April", "4 tires", "1 oil", "6 spark plugs",  
"22 Short St, Smalltown". 
       .       
   (,   ),     -
    ,     , -
,     . 
        .   
           
  string   integer.     
    ,      ,   
    integer.     -
   . 
    
          .  
       . 
  : 
 pos()  prev() 
  ,      , -
     .      
    each(),      -
  . 
       ,  -
    .   ) -
  . 
  next()  each()      . 
  each($array_name)   ,   -
 .         
   ,      -
 . 
  ,        -
.   end($array_name)     
.  reset()  end() , ,    
 . 

 3,    1 
         
 end()  prev().  prev()      -
 next().        ,   -
   . 
,         
: 
= end ($array) 
while 
{ 
echo 
= 
} 
      : 
$array = (1, 2, 3) 
       
 
2 
1 
   each(), current(), reset(), end(), next(), pos()  prev() 
         . 
      : 
         
     .     
   : 
int arr, string [mixed 
    ,  
  ,  . 
 ,    . , arr  -
,    . , func    -
 ,       .  
, userdata,  .       
      .   -
,   . 
      , -
      . 
        ,  
       
function 
{ 
echo 
} 
     .    
     ,   ,  

92  1.  PHP 
 ,        
,  : 
, 
        
    .       
   userdata. 
          -
.           
      
       ,   
       .  ,    
     ,    ,   
 . 
function 
{ 
$value *= 
} 
         -
     .     -
         
  rayMultipIyO    .     -
   ,      -
       -
    . 
      (&)  
     myMultiplyO ,  $value  
  .        
. 
       5.   ,  
         . 
  :   
          -
   count().  sizeof()     -
.          -
.        1    
  0     ,  ,   -
. 
 .    
 ,        -
 (To ,     .)   -
 ,     .  -
           
  , ,     -
   

 3.   
,   
$array = array 5, 1, 2, 3, 1, 1) 
$ = 
  $,   
 
4 
5 
1 
2 
3 
 
1 
1 
3 
2 
1 
  ,   4, 5  3     -
 , 1   ,  2  . 
    :  
   ,    -,  -
        .  
   : 
extract (array var_array [, int string prefix] 
 extract()     ,  
  ,     .   ,  
,    . 
   . 
$array = => => 
=> 
echo $key2 
     : 
valuel value2 value3 
      key2  key3.    
     $keyl, $key2  $key3.  
  ,   $key2  $key3 , -
, "valuel", 
 extract()    :  prefix. -
       -
      ,   .   
    .   -
    . 3.1. 

 4  1.   
 3.1     
  
     . 
    . 
EXTR_PREFIX_SAME      $prefix_key.   
       prefix. 
     prefix.   
       . 
       
     -
   ,   ,      
  ,       .   -
     .  , 
    
$array = => => 
=> 
     valuel 
 ,   ,   extract()  ,  
     , .. ,  -
     ,  . 
  
            
PHP-.         , -
          
    http://www.php.net. 
  
       .    -
 ,   ,    ,  -
      ,   -
     . 

 
  
 
 


      

      
.      
      
 ( ) ,     
 . 

     .   
     
,       
.  ,     
     . 


     : 

   
     
   
        
 
    
 : Smart Form Mail 

        
     Smart 
Form Mail.       
 Bob's Auto Parts,     
 . 

         
  ,   


96   PHP 
     -
,    . 4.1.  
     
     
 ,   -
  Web.     
    -
   feedback@bobsdomain.com, 
    -
      
     -
    -
   -
   . , 
    -
  "advertising" (""), 
      -
.    -
     
 . 
. . 
Customer Feedback 
Please tell us what you think. 
email address: 
feedback: 
1 
1 
4.1   , 
    
. 
,      . 
     ,  -
     . 
 4.1 processfeedback.php        
   
= 
$subject = "Feedback web 
= "Customer name: 
email: 
= 
$subject, 
<head> 
Auto Parts - Feedback Submitted</title> 
<body> 
submitted</hl> 
<p>Your has been 
</body> 
 ,        -
    , , ,  
          -
. 
      ,  PHP- -
         feedback@bobsdomain.com.  
   mail()   ,   ,  
 . 

 4.      
 ,       -
.     : 
, string , string 
string 
     , , ,  -
    ,     . 
        -
    .      
   Internet. (RFC,  Requests For Comment (  
),     Internet.   -
   17.)         -
          
 ,       -
  ,       -
 (\),     : 
     email(),    -
     .     
  ,    . 
           -
       . 
  
 ,   ( ,   HTML--
),    ,      . 
 :   
             -
.     ,    ,   
            . 
        .    
       : 
          -
 .         (\), 
  (\),   (\t)    (\v), 
  (\0)   . 
          -
   chop().      
 ,          -
 .      ,   trim() 
      ,     -
  (   ), a     (  ) -
. 
4 216 

98  1.  PHP 
    
   ,     -
   . 
 HTML-:  
           
    <BR> HTML.     -
    ,      -
        : 
<p>Your feedback (shown below) has been 
<pX? echo ?> </p> 
,  HTML     ,  
           
 (    ,  ). 
   . 4.2. 
i 
    
       echo      
. 
       ,   echo,  
   ,    (0  1,    
 ). 
     " ".   printf()  
     .  ,  
   ,    
   , a sprintfO   . 
 ,      , ,   
   -.   ,    -
  ,   ,    -
    . 
    : 
string sprintf (string format [, mixed args 
(string format [, args 
         , 
   ,      
 .    ,   
   . 
 4.2 
 
PHP- nl2br() 
  
  
 HTML. 
Customer name: Jane Smith Customer email: Customer 
comments: Thank you for providing on your website. 
With 
name: Jane Smith 
Customer 
Customer comments: 
Thank you for ordering your website. 

 4.      
,   echo   ,   -
  ,  : 
"Total amount of order is 
          -
 
printf ("Total amount of order is 
      . 
   " ".      
      . 
  ,     12.4,   
    12.4. 
    ,     
     ,    
             
,     : 
printf ("Total amount of order is 
      .  
        -
  .      -
    ,    . : 
printf ("Total amount of order is %.2 f (with shipping %.2f ) $total, 
        -
     
      
        -
     
.      -
   .        
 ,   . 
   .  ,     -
    ,    ,    . 
      ( ) -
    . 
      .   -
     . 
     .   -
    . 
,   ,        
          -
    . , \    .  , -
    ,  \t,   ,  \s,  
 . 

100  1.  PHP 
 4.1     
 
         . 
        . 
d         . 
f           
 . 
         
s       . 
           
  a-f  . 
X           
  A-F  . 
   
    .       
 , ,   ,     . 
   ,     
,       .   -
   . 4.2. 
 4.2        
 
  
    
strtolower()   
    
   
 ,  
   
   
    
,   
  . 
 
strtouppper($subjecf) 
ucfirst($subject) 
 
Feedback from web site 
FEEDBACK FROM WEB SITE 
feedback from web site 
Feedback from web site 
Feedback From Web Site 
   :   
       , 
           
    .           
 II,            -
. 
      ,   -
  ,       ,    
    .    -
 (  ),     (\)   

 4.      
    ,    ,   
 ,  MySQL,  ,       -
  ,        -
.    ,     
  . , ( )    \   \\. 
(      ,    
   \\     \\\\.) 
    ,      
.          -
    : 
= 
    ,   
      . 
          
  .          
.       
= 
        -
  . 4.3. 
  ,       . 
    .     -
 21. 
       
 
      . ,  -
     (,   )  
         .  -
    (    ), 
   . 
    ,      
   ,     -
 ,  ,      , , 
      . 
 4.3 
   
  
  
 .  
 
  . 
Customer before 
customer representative told "We give any guarantees." 
What of is ? 
Customer feedback 
Your customer service representative told give any 
What kind of is that? 
Your customer service representative told me, "We give any 
What kind of service 

  1.  PHP 
  
 , explode(),        , 
  : 
array separator, string 
    input        -
  separator.      . 
           -
  : 
$email_array = 
        -
   :  ,      -
,          
        -
 : 
if 
= 
else 
$toaddress = 
 ,       ,  -
   .      ,   
      ,    : 
= strtoupper 
,     , -
    . : 
= 
          
,    .       
  explode(),    . 
  strtok() 
          , 
   ( )    -
.        explode()  
     . 
    : 
srting input, string 
   separator      -
,     ,         -
 ,       (     
explode). 
    ,   ,   . 
         strtokQ  -
,     ,  .   -

 4.      3 
         -
.         
.    ,      -
. 
 ,    : 
= 
while 
{ 
= 
echo 
 ,   , ,    -
    -   .    
   . 
          
       .  ,  - 
   ,   .       
   (       -
)    .      -
,      .  ,    
  0,     .     --
   ,   .     -
 
  
        -
     .      ,   
 ,       -
 . 
 substr()   : 
, int , int [] 
      . 
      : 
$test = "Your customer service is excellent" 
          (-
),   ,        . -
, 
1); 
  "our customer service is excellent".  ,  -
     0,   . 
       ,  
 ,      ,   -
  . , 
  "excellent". 

104  1.  PHP 
        , 
    (  ),    
  (  ). , 
0, 4) 
    ,   "Your".  : 
($test, 4, 
 ,        -
    , .. "customer service". 
  
            
  .         
.       :     
.      ,     -
 ,       -
  Smart Form. 
 :  strcmp(),  
      ,    
 . 
  strcmp()   
int string str2) 
   ,    .   , 
   0.        
 (  ),    .  -
      .  -
    . 
     ,    
  . 
       -
   4.        " 
",     . , strcmp() -
   "2"   "12",    . -
 strnatcm()       .  -
     http://www.linuxcare.com.au/projects/natsort/ 
      
          
 ,    . ,   
5. 
       .  
      ,    
        , 
   email    .    -
         ,  

 4.      
      -   , -
      ,    
 a@a.to. ,       -
,     : 
if < 6) 
< 
echo "That email address not 
exit; //   PHP 
} 
,       . 
      . 
       
 
         . 
     ,     -
 . 
   Smart Form       -
           -
 .    ,     
  ,     ,  , 
     "shop" (  ). 
   ,     -
 explode()      ,   
,   ==   
,            -
     .     
    .     
 . 
  :  
           
 
         -
       .  , 
          
,        ,   --
.             
,      ,     . 
   : 
string haystack, string 
      haystack,    -
 ,   needle,   .    -
    needle     haystack, -
   needle;       false. 
  needle    ,    -
     needle. 

106  1.  PHP 
,   Smart Form     -
     : 
= //   
//  $toaddress   
if 
$toaddress = 
else if 
$toaddress = 
else if 
$toaddress = 
         -
        . , 
,     "I still haven't received delivery of my last order", 
     "delivery",       
        -
  ,     .     
,      "delivery", "Delivery"  
         
strstr(),      haystack,    -
  needle. 
  :  strrpos() 
  strrpos()     -
 ,         needle 
  haystack. 
   : 
string haystack, string needle, int [offset] 
       needle 
  haystack.  ,      . 
,     4   : 
$test = "Hello 
echo 
      needle    ,   
    . 
  offset       
haystack,     . , 
echo ($test, "", 5) 
    7   ,     
   5  , ,       4. 
    ,     -
   needle   haystack.     strposQ,  
    -  needle. ,  -
   needle,       -
  . 
    ,  needle   ,   
   false.    ,  

 4.      / 
       false  0, .., 
   . 
       ===   -
 : 
$result = strpos($test, 
if === 
"Not found" 
else 
echo "Found at position 0"; 
 ,        4   -
     , ,    
  (..,  false). 
 : 
        
     .         
 ,  , ,   
  , a address   .    -
     , ,   -
      Smart Form. 
        -
     . 
 ,        
   : 
string string 
       needle   haystack  
 
,      Smart Form  
  ,       
.  ,      -
      : 
= 
       -
  .    : 
string string 
int start, int ) ; 
      string  replacement.  -
       start    length. 
 start     ,    -
 .    0  ,     -
 ,       . ,  -
        $test  "X": 
$test -1) 
 length    ,    -
  .     ,     -
,   start,    . 

108  1.  PHP 
  length  ,      
     . 
   length   , -
    . 
   length  ,   -
   ,    . 
    
      : POSIX  Perl. 
       ,   
 ,     PCRE (Perl-compatible 
regular expression  Perl-  ).    
  POSIX,   Perl  ,    
  PCRE,       http://php.net. 
           
 .        
 . ,       -
 ,  "shop"  "delivery". 
         -
      ,  -
  ,  -   . (  
    ,     .) ,  
"shop"    "shop".    -
  "ho"  .. 
         
   . 
,      ,    
     ,       -
      .    -
   .     . 
   
       -
       .  
        
  ,       . 
 ,         
   ,      -
,   
,  ,  "cat", "sat"  "mat". 
         
    . 
,   ,     -
,   ,     ,  -
   .      -

 4.    
  "mat"  "cat",        
       ,    -
 : 
,       [  ], -
     ,     -
 .  ,      -
     . 
     . , 
[aeiou] 
    . 
   ,         -
 ,   : 
[a-zA-Z] 
         -
 . 
      ,     
 . , 
  ,     a-z.    
  ,    "".    
     ,    . 
          -
     ,    
. 4.3. 
 4.3  ,      
 
-  
  
  
  
  
 
  
    
    
  
   
 ,     

no  1.  PHP 
        
   .         
  .  * ,      
  ,   +  1   .     -
    ,    . , 
 "    - ". 
 
     , , ,  
   "      ,    
   ".        -
  ,      . , 
(very 
  "large", "very large", "very very large"  .. 
  
  -       
,     ({}).      
     3 ),   
4}   2  4 )     -
    ). 
, 
3} 
  "very", "very very"  "very very very". 
      
 ,       , - 
     .   ,   -
,          . 
         
,        ,   $ 
       ,    -
   . 
,      bob   -
: 
     com   : 
, ,          z, 
   : 

 4.      
         -
  (|). ,     com, edu  net, 
  : 
(com) I (edu) | 
     
      ,    -
,   ., {  $,        (\). 
     ,      
 , .. \\. 
    
       . 4.4  4.5.  . 4.4 
      ,   . 4.5 -
    . 
 4.4    ,  
  
  
\  
    
$     
  ,      
   
(   
)   
 0    
+  1    
{   /   
  /   
 4.5   ,    
 POSIX    
  
\   
,       
     
     Smart Form 
  Smart Form    ,   
,   . -     -

112  1.  PHP 
   .      
   .      -
  "shop", "customer service"  "retail"    -
 .         
  : 
shop I customer 
         
        -
 .    -   -
 ,     @,   - 
  ,  ,   -   -
 , ,  ,    ;   -
  : 
  "       
,    ,  -  ". 
 @    @. 
 [a-zA-ZO-9\-]+     , -
 -   .  ,   -
    ,      -
  . 
 \.    
 [a-zA-ZO-9\-\.]+$     , 
 , ,    ,   , 
   . 
  ,      -
 ,        . -
      ,    
  -   . 
,      ,  -
 PHP-,    . 
      
         -
.     ,     -
 : ereg()  eregi(). 
   : 
int string search, array 
      search,      
 ,    pattern.   -
   pattern  ,     -
 matches,       . 
 eregi()  ,   ,    -
  . 

 4.      
 Smart      -
  : 
if 
$email) ) 
{ 
echo "That is not a valid email address. Please return to the" 
. previous page and try 
exit; 
} 
$toaddress = //   
if 
$toaddress = 
else if 
$toaddress = 
else if 
$toaddress = 
if 
$toaddress = 
      
          
 ,          -
   : ereg_replace()   
  : 
string string string 
     pattern   search    
 replacement. 
  ,     . 
      
        split(),  
  : 
array pattern, string search, int 
    search      
pattern     .   max  
 ,      . 
          . -
, 
$domain = 
$arr = split 
while $value) = each 
echo 
            
    . 

114  1.  PHP 
      
 
        -
,      .   -
 ,      ,  -
 . 
  
     .   
 UNIX,         
,   ,     
  devshed.com  
 Web-  Zend       -
       -
 ,  ,     .   MailVal() 
    
          
    ,       -
   . 
  
          
   ,   ,   -
       . 

 
  
   
  ,   -
      
, ,    -
       -
.         
  ,    -
   include()  -
        .  
,        
 .    
    -
    . 
 ,     -
 ,      
   . 
     : 
      ? 
    
    
      ? 
    
  
   
        
   
  

116  1.  PHP 
     ? 
  ,      , -
      .      
,       . -
     ,  -
   .        
       -
    . 
     -   -
 , ,     -
   ,    .   
       , 
  .       
         -
         .    
  .     , -
    ,   .  -
       -
   .   ,   
  ,    -
 ,   .   -
      . 
        , , 
   .        , 
      -,  
          
  .  , ,    -
,  , "". 
 
  ,     -
  ,   .   ,  -
    ,     
.    ,      -
,     . 
  ,       
  ,   ,      -
   .         -
 ,        . 
   
PHP   ,    ,  -
     .   require()  include(), 
    PHP-.    ,   -

 5.       \ 
  ,  PHP-, , HTML-, 
  
      (Server Side 
Includes),    Web-,   
    C++. 
  
     reusable.php: 
echo "Here is a very simple PHP 
      main.php: 
echo "This is the main 
"reusable.php" 
script will end 
,  ,     reusable.php    
  "Here is a very simple PHP statement."     
main.php  -  .      . 
5.1. 
in php 
 5.1 
,  
 main.php, 
  
  
Edit 
This is the main 
Here is a very simple PHP statement. 
The script will end now. 
       -
  reusable.php.      
   ,    .  
,     main.php   ,    -
   : 
<? 
echo "This the main 
is a very simple PHP 
script end 
   require()       
     -. 

118  1.  PHP 
     
        . -
,     ,      -
 .      ,  
   PHP-     . 
 PHP-   ,     , -
, , page.html.  ,      -
   ,   .php.     
page.html       PHP-  
. ,       -
,        -
   
     ,   ,   .inc  
-   ,     Web, 
      ,     
   ,      .    
     ,    
. 
  requireQ 
       -
 : 
echo "Here is a very simple PHP 
  PHP-    PHP-.   ,  
,  PHP-       
PHP-.   PHP-,       
 HTML    . 
  
  
Web- 
   Web-  -
    , 
      
      
  
, Web-  -
 TLA Consulting   , -
       -
  . 5.2. 
     -
,    -
 ,    
 ,      
   . 
Beck 1 
TLA Consulting 
Home  Map 
Welcome to the home of TLA take some 
time to get to know us. 
We in serving your business needs and hope to 
hear from you soon. 
 5.2  Web-  
 TLA   
  . 

 5.       
     : Web- -
       ,  , , -
 ,      .    
       - , 
,        -
        .   -
      ,    -
 ? 
   HTML,      -
   ,    ,   
,    .     
  . 5.2,    
5.1 -    
 TLA _ 
Consulting Pty 
<style> 
td 
p 
</style> 
page header 
<table cellpadding = 12 =0 border = 0> 
<tr bgcolor = black> 
<td align = src 
Consulting</hl> 
<td align = = 
</tr> 
menu --> 
width = bgcolor = white cellpadding = 4 cellspacing = 4> 
<tr > 
<td width = 
<img src = <span 
<td width = 
src = <span 
<td width 
<img src = 
<td width = 
<img src = <span Map</spanX/td> 
</tr> 
</table> 

  1.  PHP 
content 
to home of TLA Consulting. 
Please take some time to get to know </p> 
specialize in serving your business needs 
and hope to hear from you 
<!-- page footer 
width = bgcolor = black cellpadding = 12 border = 
0> 
<tr> 
<td> 
<p TLA Consulting Pty 
<p class=foot>Please see our <a href 
legal information page</aX/p> 
</tr> 
</body> 
    5.1,        . 
HTML-  CSS- (Cascading Style Sheet, CSS), -
 . ,  "page header" ("  "), 
     , "menu" ("")   
, a "page content" (" ")  ,   
 .      .  -
       header.inc, home.php  footer.inc.  
 footer.inc  ,       
. 
 home.php        -
         5.2. 
 5.2 home.php      
 TLA Consulting 
<? 
?> 
<!-- page content 
to the home of TLA Consulting. 
Please take some time to get to know 
specialize in serving your business needs 
and hope to hear from you 
<? 
   home.php   header.inc  footer.inc. 
  , ,   ,     
      ,   -
,   ,       
,  (   inc  include 
 ,         , 
  ,       -

 5.       
  Web-.    -
  ,   )  - ,   -
  .php,        ,   
       . 
 header.inc  CSS-,   , -
,    ,    (.  
5.3). 
 5.3 header.inc      
  Web-   
<head> 
Consulting Pty 
<style> 
td 
p 
</style> 
</head> 
<body> 
<!-- page header 
<table cellpadding = 12 cellspacing =0 border = 0> 
<tr bgcolor = 
<td align = leftximg src = 
Consulting</hl> 
</td> 
<td align = src = gif 
menu --> 
<table width = bgcolor = white cellpadding = 4 cellspacing 
= 4> 
<tr > 
<td width = 
<img src = <span 
<td width = 
<img src = <span 
<td width = 
src = <span class=menu>Services</spanX/td> 
<td width = 
<img src = <span class=menu>Site Map</spanX/td> 
</tr> 
  ,      -
   .      5.4. 

122  1.  
 5.4 -     
  Web-   
<table width = bgcolor = black = 12 border = 0> 
<tr> 
<p TLA Consulting Pty 
<p class=foot>Please see our 
<a legal information page</aX/p> 
</tr> 
        Web-, 
        ,  - : 
<? ?> 
Here is the content for this 
<? ?> 
 ,   ,    ,  
    ,       -
 .   ,      -
,      ,   
  .        , -
        . 
    ,      -
  HTML-.    .      
  PHP-     . 
   
         -
    ,      .  
php.ini    :  -
          -
   , ,     . 
 Windows    - : 
= 
auto_append_file = 
 UNIX    : 
= 
          
           
. 
  Web- Apache   , -
 ,     .      
       () . -
N 

 5.      
         , -
   ,  .htaccess.       
: 
auto_append_file 
 ,         -
   php.ini:        . 
      php.ini    -
 . 
      3.    -
       : 
        php.ini    -
 Web-     .   
    ,    -
 .      Web-      
 .       
 ,            
,        ,     
. 
  
  include()  ,     -
   . 
         -
,    .     
  ,   ,    -
   . 
     ,     ,   -
,  ,    require()    -
, . 
== true) 
{ 
} 
else 
< 
          , 
      ,      
,          
     ,    : 
== true) 
{ 

124  1.  PHP 
else 
{ 
> 
   ,     , -
      . -
,          -
   ,     . 
 ,     ,      -
       ,      
.          : 
<? 
@ $. = 
if (!$fp) 
{ 
echo Oh No! I could not open the 
return 0 
> 
{ 
return 
       ,  
           -
  0.        1   -
- . 
      : 
= 
= 
$result = 
$result == 1 ) 
{ 
//    
//      
} 
 ,       ,   
   ,       . 
     include()   . 
     ,   , -
     .     -
,         -
        . 
         ,  
 .      . 
  :     -
      include()?    ,  -
 require()   . 

 5.       
   
     .    
 ,   ,   .  -
          
. 
     ,   -
 ,    , ,  -
. 
    .       
  ,   .      , 
      .        -
  . 
  
     : 
        .  
    ,     -
. 
     .   
   ,      , 
  ,   Web-    -
   .      ,    
    ;     
 : 
         -
,             -
.        , -
 ,       .    
    : 
      ,    
parameter,        : 
      PHP-  
,     . 
     ,     -
    . 
   ,      
      ,     .  
      ;    -
       http://www.php.net. 

126  1.  PHP 
, ,     
fopen( string filename, [int 
        -
  .     int    , 
      .   -
   .        . 
 filename (_)  mode ()  , 
  . i 
   ,    -
.          -
        ,  
. 
      ,   -
      
= 
= 
$.p = 
      fopen().    
        -
 ,    ,   -
 ,      .  -
  . 
    
   ,   ,    
,    . 5.3. 
 ,       .  -
      ,    ,  
 ,     .    
    . 
        : 
1.     ? 
2.        ? 
 5.3 
    
   
,   
. 
error: Call to unsupported or undefined function 
in on line  

  
 

' 
. 

 5.       \ 
     : 
       ,    . 
      ,    -
. 
       . 
       -
.     .     -
 ,      ,    
      .   
,    PHP-    , -
       ,    
.  ,         
,      ,     -
. 
   : 
name 
() 
  : 
name-six () 
(    ,      .) 
 
     ,    
      .      
.    ,      -
.           . 
function 
{ 
echo border = 
//     
$value = 
while 
{ 
$value = 
} 
echo 
} 
   create_table()  : 
= 
   ,   . 5.4. 
5 . 216 

 1.   
. 
 5.4 
 HTML-  
  
 create_table(). 
j 
one. (I 
j| 
      ,    
     ,  
     ,     
     .  -
   ,        -
        . 
    .    ,  
     ,     -
  . 
$cellspacing=4 ) 
echo border = 
cellspacing 
$value = 
while ($value) 
$data, 
$border cellpadding = 
echo 
$value = 
echo 
   - .  
   ,       . -
,      . 5.4,     -
   create_table2(). 
 ,         , -
       : 
3, 8, 
        ,  
 .     . 
  ,    -    
  ,     .   ,  -
    cellspacing,       
cellpadding.       . 

 5,       1 
            -
. 
  : 
3) 
     ,     -
  3,      -
     . 
  
,   ,     
           -
   require()       
     .     ,   -
          -
 ,    ,       -
 . 
    ,     . 
      , -
   .      : 
 ,    ,     -
,          .  
   ,      -
. 
 ,    ,     -
,       ,    .  -
   ,     -
. 
    include()      -
.     ,   
.      ,   
. 
   global      ,  -
,      ,   
  . 
         
  ,      -
 . 
      . 
     .     
       ,   
           .  
    ,    $var.   
          .  -
,   ,      
 echo,      . 

1  1.  PHP 
function 
{ 
$var = "contents"; 
} 
echo $var 
   .    -
 ,       . 
function 
{ 
echo "inside the function, \$var = 
$var = 
echo "inside the function, \$var = 
} 
$var = "contents 1"; 
echo "outside the function, \$var = 
    : 
inside the function, = 
inside the function, $var = contents 2 
outside the function, $var = contents 1 
     ,     ,  -
    = "contents 1";    
$var,       "contents 1".  
         -
  .          
 ,        -
     ,   ,  
   .      . 
       $var 
 "contents 2".     ,   
      .    
   . 
    ,    
 .   echo ,    -
  . 
 ,  ,   ,  , 
    global,     : 
{ 
global 
$var = 
echo "inside the function, \$var = 
} 
f n 
echo "outside the function, \$var = 
        , .. -
        .   -
    : 
inside the function, $var = contents 
outside the function, $var = contents 

 5.       
 ,     ,    -
,    global       
   ,   . ( ,    
       -
       ,     , -
,     . 
  global         
    ,      -
  . ,      -
  global. 
    ,      
         . , 
      , ,       -
     ,   ,   
      . 
       
      , 
       : 
function = 1) 
{ 
$value = 
} 
   .       
 "10". 
$value = 10; 
increment 
echo 
 ,    . 
     .     
   10.     -
      .    1, -
       ,    
         .    - 
  ,    ,  
   . 
          -
   ,   ,      
,    ,    
        . 
        . 
     ,    
.     .     
 ,         -
 . 
           
 ,      ,  

  1.  PHP 
    .     , -
   ,      ,   -
 .    ,   ,    
,      .  , -
  ,     . 
       -
  (&)      .   
    . 
     ,    
  ,      . 
$amount = 1) 
{ 
= $value + 
> 
        , -
     .   ,  
            , -
        .   
      10      
  . 
$ = 10; 
echo $ 
increment 
echo 
   
  return   .   -
   ,    ,    -
   return,    , -
   . 
        echo. 
{ 
echo "This statement will be 
echo "This statement will never 
} 
,        return.  
         . 
       -
 return      . , 
,         ,  
         . 
function $, ) 
{ 
if <$) | | ! isset 
{ 
echo "this function requires two 
return; 

 5.       
if ($>=$) 
echo $ 
else 
echo 
} 
  isset() ,         
 .          
,        .   
    !isset(),  "  -
,  if    "       ". -
   ,      . 
  return ,       -
.     ,     -
.    ,       . 
  : 
$ = 1; 
$ = 2.5; 
$ = 1.9; 
$) 
$) 
$a) 
 : 
2.5 
1.9 
this function two 
    
         return.  
   return       
 .    ,        
      .      
    ,        -
  .    ()    
. 
      : 
function larger ($x, $y) 
{ 
if | | 
return 
else if ($x>=$y) 
return 
else 
return 
> 
        .   -
      .     , -
             
      .     
,     ,       
,    . 

136  1.  PHP 
          -
   .  ,       -
.    ,   4.0,   -
   ,    ,     
    .       -
         ,   -
        . 
 : 
$ = 1; $ 2.5; $ = 
echo larger($a, 
echo larger($c, 
echo 
  : 
2.5 
1.9 
 ,    ,    -
 ,   true  false      
 .  true  false    -
  1  0. 
  
         .  
      ,      
        ,    -
 . 
     . 
    
= 0; $i < 3; $i++ ) 
echo "Line 
echo "Line 
    
= 0; $i < 3; $i++ ) 
< 
echo 
echo "Line 
} 
    for   .     -
 ,     ,   
 for. ,   ,   : 
Line 1 
Line 
Line 1 
Line 2 
         .  -
,       for  . ,   
,  : 

 5.       
Line 1 
Line 2 
Line 1 
Line 2 
Line 1 
Line 2 
        , -
,        .    -
    ,      for.  
 ,         . 
         ,    
  . 
 
   .    -
,    .       
   ,      . 
   Web-     , 
    .      -
  ,        
   .       -
  ,  ,       
 . 
     ,    5.5. 
 5.5 recursion.php        
     (   ) 
function 
{ 
if 
echo 0, 1} 
} 
function 
{ 
for $i++) 
{ 
echo -$i, 1) 
} 
     .       
.   , a reverse_i()  . 
 reverse_r()     .     
   ,         -
. 
,    
       : 

138  1.   
          -
   ,    .    ,  
      .   -
    . 
      .    
    (strlen()==0).     
        , 
           -
,   . 
      ,  -
 ,          
, "",      . 
         , -
          ,     
  . 
       . 
,       .   
       5.5.  ,   
      (    
     )      . 
      ,    -
       , ,    
,     . 
    ,    -
      ,     -
   . 
    ,    -
   .  ,     -
    ,           -
   ,    ,   . 
  
  function  return  -
   .     ,  , 
  /   ,    -
 ,       . 
  
,          
  ,         -
   ,     --
      .    
 ,  ,    ,    -
        . 

6 
-
 
 
 PHP 
    -
      
. 
      
  - -
 
 ,    
   
   
 
   
  
   
 - 
 
    -
     
     .  
 -  
   , 
      -
 . 

 1.  PHP 
   
  -    -
          ,  
   ,    ,   
 ,      .      
  ,     ,  -
    . 
-       
   ,    ,  -
     .   -
   ,    .   -
 ,   ,       
   -  . 
  -   
       , -
   .  ,      -
    ,   . 
,  ,      
.         -
,         
  ,        . 
      - 
  ,  -   
 .  ,       Web 
        , 
 - . 
    .   Web-  -
  .         
 ,     ;      -
        Web, -
  .       ,  
       ,     -
         . 
   Web    ,  -
,    .   , -
         HTML--
,      .   
     ,  -
     ,  ,    
. 
 -       
      ,  
. ,     ,   . 
       60    20 -
       ,      
     .       -
,     ( ) -
. 

 6. -   
    .    , 
     ,     .  -
 ,      ,   
     ,      
    . 
""      , -
   ,    ,  
      ,   ,     
, , . 
    ,    . 
   ,   ,   -
,    ,     -
       .   -
   ,   , ,  ,   
   . 
 
-     -
  ..           -
. ,        -
    .       
  .         
       -
 .        -
 ,     ,  
,        -
 . 
     ,  .   
 -    . -  -
    .      , -
  , ,   . 
    ,  ,    
  . (         -
   .) 
,         -
,     ,       . -
           ,  
 ,    . 
 
        
 .       . -
,       .    
   ,   ,   
   ,    ,   -
       . 
 ,      -
 .          
     .     -

142  1. PHP 
   ,       
- . 
      , 
           
    .      -
  .       "-
"  , ,      . -
 "   "  ,   
"   "  ,    -
   . ,   -
  . 
      
       .    
     class. 
  
     : 
class 
  ,      .  -
         -
      classname   : 
 
class classname 
{ 
var 
var 
} 
       . -
    classname   ,    -
 .     ,   
operation2()   . 
class classname 
{ 
function operationl () 
{ 
} 
      ,  -
.          
   ,      
    ,    . 

 6. -    
   ,   ,     
,   .     ,  ,  -
       .   
   : 
class 
{ 
function 
{ 
echo "Constructor called with parameter 
 ,        ..  -
       ;    -
   . (     -
- .) 
   
         -
,   ,     .   
    .     -
  new.    ,     ,  
  ,    . 
    classname  ,     
  classname: 
class classname 
{ 
function 
{ 
echo "Constructor called with parameter $param 
$a = new 
$b = new 
$c = new 
      ,    
 : 
Constructor called with First 
Constructor called with parameter Second 
Constructor called with parameter 
   
          -
           
          

  1.  PHP 
          : 
class 
{ 
var 
function 
< 
$this->attribute = 
echo 
         
      .     
,         (..   
). 
       ,    
: 
class classname 
{ 
var 
} 
$a = new 
$a->attribute = 
echo 
          .  
  -   ,    -
.        ,  -
      . 
         , 
         . 
         -
: 
class classname 
{ 
var 
function 
< 
return 
} 
function 
{ 
$this->attribute = 
           
       
       
         . ,   
 ,    ,   ,     -
 :           
    . 

 6.    
         , 
      .   , 
        0  100,  
          ,  
 .  set_attribute()    : 
function 
{ 
>= 0 && <= 100 ) 
$this->attribute = 
} 
  ,        , 
           -
      . 
        , -
   .   -     -
      ,    
  . 
 ,        
    ,       , -
 ,     ,      
   .      , -
    .         
  ,         -
,    . 
   
         . 
,    : 
class 
{ 
function 
{ 
} 
function 
     classname   $  : 
$ = new classname () 
     ,    : -
         .    
 ,    ,   , -
  .     ,   : 
   -,      
: 

146  I.  PHP 
$ = () 
$ = (12, 
    
      ,     -
   extends.     , -
      . 
class  extends A 
{ 
var $attribute2 
function 
       : 
class A 
{ 
var 
            -
: 
$ = new B() 
$b->operationl 
$b->attributel = 
$b->attribute2 = 10; 
 ,        ,  - 
   ,      
  .    ,      -
   .  ,      
  . 
 ,       . , 
  ,     ,  -
,         . 
 ,        : 
$ = new A() 
$a->attributel = 
$a->attribute2 = 10; 
       
  ,       -
         .  
       ,  -

 6.    
         ,    
     ,     -
  .     . 
,    : 
class A 
< 
var $attribute = "default value"; 
{ 
echo 
echo "The value of \$attribute is 
         -
       
 ,      operation(): 
class  extends A 
{ 
var $attribute = "different 
function operation () 
< 
echo "Something 
echo "The value of \$attribute is 
          -
    : 
$ = new 
$ -> 
             
  
The value of is default value 
 ,       .     ,  
 . 
 
$ = new 
$ -> () 
  
else 
The value of $attribute different value 
  ,          -
   ,       -
    . 
        ,   
     .    ,  -
     . 

148  1.  PHP 
     - ,   -
   ,    , -
   . 
   .    ,  -
   , ,        -
            
 ,    . 
  
 -    -
,     .  ,      
     .   , 
   ,  . 
      .  . 6.1   -
        . 
 6.1 
   
 
. 
 
I 
 
 
  
 
 
  
   ,       , ,   
,    .       -
 , ,        -
. 
    ,         . -
       , ,    -
  . 
 ,          .    
     , ,    -
     . 
  
,     ,    -
  ,       ,    -
  . 
          
. , , ,     Web--
,   ,   , -
 ,     . 

 6. -   
         
   ,  ,    -
 ,         
 .       -
.  ,  ,   , 
     . 
         -
    Web-   TLA 
Consulting.       , 
  ,       
 . 
         -
     .        -
  ,     . 
    Page.       
 HTML-,     .    
  ,      ,     
  ,  . 
        ,   
     . 
    ,      
HTML,      ,     
 ,    : 
       . ,  -
        
        . 
         
     ,   , -
     ,    
 ,    ,   -
    ,    -
 ,      ,   . 
       . , 
        , 
     . 
   
 ,         -
   ,     ? 
         . 
     ,    -
- -. 
   .    ,  
 Page.    Page   
class Page 

150  1.  PHP 
   . , , , -
     ,      . -
  ,    HTML-  
,        -
    : 
var 
       . , 
  ,       -
 .    ,    
    : 
var $title = "TLA Consulting Pty Ltd" 
  Web-    -
     .    -
, , ,      .   
      : 
var $keywords = "TLA Letter 
some of my best friends are search engines"; 
 ,      . 5.2 (. -
 ),  ,      , -
   ; ,    ,    
.     ,     
     ,  Web-,     . 
var $buttons = "Home" => 
"Contact" => 
=> 
"site Map" => 
    ,   
 .          
      .    
  : 
function 
{ 
$this->content = 
} 
 ,         
,         GET. 
      HTML-,    
 .       : 
function 
{ 
echo 
$this -> 
$this -> 
$this -> 
echo 
$this -> 

 6. -    
$this -> 
echo 
$this -> 
} 
      echo   
HTML-,         . , -
,     ,     . 
      .    -
        .       
. 
     .    ,  
    .       -
        ,  
   . 
 ,    .   
         -
  .        -
          -
,   . 
 Display   DisplayTitle(), 
DisplayHeader(), DisplayNenu()   ,    
 .     4     3  -
        ,   
     .   3     
     ,     . 
         -
    HTML- , ,  . 
 ,       page.inc    
   ,    
 6.1 page.inc   Page      
  
<? 
class Page 
{ 
//  Page 
var = "TLA Consulting Pty Ltd"; 
var = "TLA Consulting, Three Letter 
some of my best friends are search engines"; 
var = "Home" 
"Contact" => 
"Services" => 
"Site Map" => 
//   Page 
{ 
= 
} 
function 
< 
= 

152  1.  PHP 
function 
{ 
= 
( 
function 
= 
> 
function 
echo 
-> () 
-> 
-> DisplayStyles () 
echo 
-> 
-> 
echo 
-> 
echo 
} 
function 
< 
> 
function 
< 
echo 
function 
<style> 
p 
</style> 
function 
= 12 cellspacing =0 border = 0> 
<tr bgcolor = black> 
<td align = src = 
Consulting 
align = src = 
</tr> 
function ($buttons) 
echo width = bgcolor = white" 
cellpadding = 4 cellspacing = 
echo 
= 

 6. -   
while $url) = 
{ 
-> $url, 
echo 
echo 
function 
( ) 
{ 
return 
else 
{ 
return true; 
} 
} 
function = true) 
( 
if 
{ 
echo = 
<a href = 
src = alt border = OX/a> 
<a href = 
} 
else 
{ 
echo width = 
src = 
} 
function 
{ 
width = bgcolor = black = 12 border = 0> 
<p TLA Consulting Pty 
<p see our 
<a href information 
     ,   
 DisplayFooter()      
HTML-   - PHP-.     -
   (?>),  HTML-,   
   - (<?)    . 
      .   -
  .      ,   -
  ,          
  .       
     . 
 IsURLCurrentPage() ,      
Internet-   .     .  

154  1.  PHP 
       
 Internet-    ,  .  
)    ,  -
,    $url,     
  false,    . 
    ,     -
     
,    6.2,      -
 TLA Consulting   ,     -
     . 5.2. 
 6.2 home.php         
   ,     _ 
require 
$homepage = new 
$homepage -> to the home of TLA Consulting. 
Please take some time to get to know 
specialize in serving your business needs 
and hope to hear from you 
$homepage -> 
   6.2   : 
1.   require     page.inc, -
   Page. 
2.    Page   
3.        
  HTML-,    . 
4.      -
     . 
    6.2,       -
 Page      .  -
        . 
 ,        -
 ,    page.inc      
   .         
  page.inc          
         
,        
 Page,    ,   . 
   ,      
 . 
,    6.3,   ,    
   Page.      -
     ,    . 
 ,         -

 6. -   PHP 
,      ,   
   Display(). 
 6.3          Page,  
        
<? 
require 
class ServicesPage extends Page 
{ 
var = "Re-engineering" => 
"Standards Compliance" => 
"Buzzword Compliance" => 
"Mission Statements" => 
echo 
$this -> 
$this -> 
-> DisplayStyles () 
echo 
-> 
$this -> 
$this -> 
echo 
$this -> 
echo 
$services = new ServicesPage 
$content TLA Consulting, we offer a number of 
Perhaps the productivity of your employees would 
improve if we re-engineered your 
Maybe all your business needs is a fresh mission 
statement, or a new batch of 
$services -> 
$services -> 
  DisplayO      ,  
   
$this -> 
        . 
       ServicesPage,  
,       ,   -
 Display(). 
   . 6.2,      .   
       . 
    PHP-   -
. ,      ,    -
     .     -
,   .  ,     
  ,      
,      ,     . 

156  1.  PHP 
 6.2 
  
  
 
   
  
  
 . 
file fcjeip 
Home 
TLA Consulting Pty Ltd 
 Standards 
Services 
Buzzword 
Site Map 
Mission 
At TLA Consulting, we offer a number of services. Perhaps the productivity of your 
employees would improve if we re-engineered business. Maybe all your business 
needs is a fresh mission statement, or a new batch of buzzwords. 
        ,   
   HTML-       .  
    ,      
HTML-,      ,   
  . 
  
   MySQL.       
 MySQL,         
     Web. 

 
MySQL 
7 
8 
9 
10 
11 
 Web- 
Web-  
    MySQL 
    MySQL  Web 
  
  MySQL 

 
Web-  
,       , 
     
   . ,  ,   2 
    
     .  : 
       -
,   . 
        
 ,    -
. 
      -
   ,   ,  
,     . 
      -
. 
      -
. 
   ,   -
        -
     , : "  
"     
?"  "    ?" 
     ,   
   ,    .  -
       , 
      (  -
),    : 
      -
. 
  Web- . 
  Web- . 

 7.  Web-  
  : 
  8   ,    
  MySQL  Web. 
  9 ,      ,   -
 ,    . 
  10      MySQL,   -
       Web-. 
      MySQL,  -
       Web-. 
      
      , ,  
 .        
.        (   
     ,  
        . 
 
      ,   
.     ,       . 
  -      , , 
        . 
 . 
 . 7.1   .        
  
 7.1 
   
 
  . 
CUSTOMERS 
D 
1 
2 
3 
Name 
Julie Smith 
Alan Wong 
Michelle Arthur 
Address 
25 Oak Street 
1/47 Haines Avenue 
357 North Road 
City 
Airport West 
Box Hill 
Yarraville 
     Customers (),   , 
      ,  ,   -
 . 
 
          -
.      . ,   
Customers  . 7.1  ,    -
  ,      .   
    . 
 
      .   
        .      
. 

160  2.  MySQL 
 
      ,  -
.     ,  . 
 
  .         -
      , ,  -
. ,   Julie Smith   Customers.    -
,           . 
    Julie  .  , , , 
    Julie Smith,    "25, Oak Street, Airport West". 
         .   
       . 
    (,     )  -
    ( ).  
  ,   ,    ,   ,    
  .        -
   ,       . 
  ,    ,     
   . 
        .  
    . , ,   -
 Julie  "Julie Smith, of 25 Oak Street, Airport West",    : 
Name (), Address (), City (),      
. 
      ,     
  .  . 7.2      .   -
 ,  .     Orders () -
  ,   .  ,   , 
   ( ). ,  , -
    2  ,      CustomerlD 
,    Customers, ,  CustomerlD 1  -
   Julie Smith. 
CUSTOMERS 
 7.2 
   
Orders  
   
Customers. 
CustomerlD 
1 
2 
3 
Name 
Julie Smith 
Alan Wong 
Michelle Arthur 
Address 
25 Oak Street 
1/47 Haines Avenue 
357 North Road 
City 
Airport West 
Box Hill 
Yarraville 
ORDERS 
OrderlD 
1 
2 
3 
CustomerlD 
3 
1 
2 
4 
Amount 
27.50 
12.99 
74.00 
6.99 
Date 
02-Apr-2000 

 7.  Web-  
       -
.      Customers,    -
   , , Orders,     . 
,         -
      Julie   Orders?    -
   . 
 
          .  
-   .        -
,   ,        -
 .      ,  , ,  -
     ,  ,  , 
    .      ,  -
 ,    "-" (     -
)    ,  : 
Name, Address, City) 
CustomerlD, Amount, Date) 
         , 
   . ,  ,   -
   ,     - . 
 
        . -
,  Orders  Customers       Orders 
    Customers. 
        .  -
         . -
   "  ", "  ", "  ". 
 "  " ,        
 . ,       Customers,   -
- ,      "  ".  
Addresses  Customers         ( 
  ). 
  "  "        -
   .     Customer ()  -
  Orders ().    ,    -
 ,         .   
   ,   CustomerlD   Orders. 
    "  ", ,   
      . ,   
 Books ()  Authors ().      
,       ,      
       .   ,  -
,       ,        Books, 
 Authors,  Books_Authors.         
6 216 

162  2.  MySQL 
     ,  ,    -
   . 
   Web-  
 ,        -
 ,   ,     . , -
,     ,   "-
-"    .      
.   ,      . -
      
  ,    
    ,  ,     
         . 
     ,  ,  
 . :       
  ,       "",   
  ,   . 
    "Book-O-Rama"    ,  -
     .    -
: ISBN, ,   . 
  ,  ,     ,  ,  
: Customers (), Orders ()  Books ().   -
  . 7.3. 
  ,   ,  ,    -
   .     . 
CUSTOMERS 
1 
2 
3 
Name 
Julie Smith 
Alan Wong 
Michelle Arthur 
Address 
25 Oak Street 
1/47 Haines Avenue 
357 North Road 
City 
Airport West 
Box Hill 
Yarraville 
 7.3 
   
  Customers, 
Orders  Books. 
ORDERS 
1 
2 
3 
4 
CustomerlD 
3 
1 
2 
4 
Amount 
27.50 
12.99 
74.00 
6.99 
Date 
02-Apr-2000 
01 
BOOKS 
ISBN 
0-672-31687-8 
0-672-31745-1 
0-672-31509-2 
Author 
Michael Morgan 
Thomas Down 
et 
Title 
Java 2 for Professional Developers 
Installing Debian 
Teach Yourself GIMP in 24 Hours 
Price 
34.99 
24.99 
24.99 

 7.  Web-  163 
    
    : "     -
 Julie Smith   Orders?" 
 Julie      (    
),       .    Orders 
  ,   . 7.4. 
ORDERS 
OrderlD 
12 
13 
14 
15 
Amount 
199.50 
43.00 
15.99 
23.75 
Date 
25-Apr-2000 
29-Apr-2000 
30-Apr-2000 
D 
1 
1 
1 
1 
Name 
Julie Smith 
Julie Smith 
Julie Smith 
Julie Smith 
Address 
28 Oak Street 
' 28 Oak Street 
28 Oak Street 
28 Oak Street 
City 
Airport West 
Airport West 
Airport West 
Airport West 
 7,4  ,     ,  
         . 
     . 
-,        . -
    Julie ,      -
 ? 
-,      , ..  ,   
  ,     .  -
 ,   ,  ,   .  -
,      . 
     :  , -
  . 
 Julie,  ,    ,       
,    ,      .     
    ,      ,   
         .   
  ,      
  . 
  ,     Julie  ,  -
;  ,   ,    -
   .    ,      
        Julie. ,   
 ,  Julie   Airport West,      Airport.  -
   ,     . 
     ,   (-
,  !!!)      .   ,  
      .  ,     
 Julie ,      Orders.   ,    
     Julie.      - -
 ,    ,     -  , 
     . 
   ,    ,     
   . 

164  2.  MySQL 
    
 ,          -
. ,  ,      -
.     . 
    Orders ,       
 ,    . 7.5. 
ORDERS 
OrderlD 
1 
2 
3 
4 
3 
1 
2 
3 
Amount 
27.50 
12.99 
74.00 
6.99 
Date 
02-Apr-2000 
15-Apr-2000 
19-Apr-2000 
Books Ordered 
0-672-31697-8 
0-672-31745-1, 0-672-31509-2 
0-672-31697-8 
0-672-31745-1, 0-672-31509-2, 0-672-31697-8 
    Books Ordered ( )    
  . 
        .     -
       ,     
 .   ,       : 
"    ?"     -
  ,     .    -
   ,      . 
       ,   ,   
,    .   ( -
)    . 7.6. 
ORDER ITEMS 
 7.6 
   
  
  
OrderlD 
1 
2 
2 
3 
4 
4 
4 
ISBN 
0-672-31697-8 
0-672-31745-1 
0-672-31509-2 
0-672-31697-8 
0-672-31745-1 
0-672-31509-2 
0-672-31697-8 
Quantity 
1 
2 
1 
1 
1 
2 
1 
      Orders  Books.   -
   ,        
"  " ..        ,  -
-     . 
   
   ,    .      
     (CustomerlD)    (OrderlD), -
        ,  
  .      ,  
      ISBN.  Order_Item ,  ,   , 
     Order_Item  ISBN     

 7.  Web-  165 
,             
  .      Order_Items   
Quantity (). 
     
 , ,          
. (,       . ,   
   ?)     -
, ,         -
     . 
       
         , , 
  ,  ,   .    . 7.7. 
BOOKS 
 7.7 
  
,  
   
Books  Review 
(),  
  
  . 
ISBN 
0-672-31687-8 
0-672-31745-1 
0-672-31509-2 
Author 
Michael 
Thomas Down 
et 
Title 
Java 2 for Professional Developers 
Installing 
Yourself GIMP in 24 Hours 
Price 
34.99 
24.99 
24.99 
Review 
BOOK_REVIEWS 
ISBN Review 
     Review   Books.   
       .     -
             -
     (,  ,    ). 
          -
.          , -
         . 
     ,   ,  :  -
 ,     ,     . 
   ,     
 .      ,   . 7.7.  
  ( )      
( ). 
,          -
.         .   
    
  
 ,    ,     ,  , 
   : 
  ,   .      
  ,     "  -

166  2.  MySQL 
"  "  ". ,      
,           . ,  
    . 
 ,     "  -
"    , ,  Orders  Books. -
       . 
 Web-  
,      ,   
     Web-      
. 
  Web-  . 7.8.   -
   : Web-  Web-.     
 . Web-    ,    .  
,    ,   . 
  ,      ,  . 
 7.8 
  / 
  Web- 
 Web-  
 . 
 
 
 Web- ,       
,    Web- ,   . 7.9. -
      . 
 
6 5 
 
4 
 MySQL 
 7.9   Web-     Web-, Web-cepeep, 
     . 
  Web-    ,   
 . 7.9.       
1. Web-    Web-. 
,    "Book-O-Rama"  ,   -
 (Laura Thomson),  HTML-.    -
  
2. Web-    results.php,      -
   . 

 7.  Web-   
3.      .   -
           (-
 ).      MySQL   -
 . 
4.  MySQL     ,  ,   -
     ,       
. 
5.     ,   -
   HTML,      HTML- Web-
. 
6. Web-  HTML  ,     
   . 
 ,  ,     ,   
      .    
Web-,          . -
,          .    
 ,     .    
 ,     ,    -
      . 
  
         
 .         , -
     (,   (. J.  
  ,  ,   ,     
          Web--
.        . 
  
        MySQL.   -
    MySQL  Web    ,   -
   -. 

 
 
Web-  
        
 MySQL    Web-.  
  : 
   . 
   . 
     MySQL. 
   . 
    MySQL. 
        
    
  "Book-O-Rama": 
Name, Address, City) 
Orders(OrderID. Amount, Date) 
Author, Title, Price) 
ISBN. Quantity) 
Reviews) 
He ,     
 ,     . 
    , -
    MySQL.    -
, : 
1.    MySQL  Web-, 
   : 
   
   MySQL 
  
    

 8.  Web-  
     root 
    (anonymous) 
   MySQL      . 
   ,       ,  
       . 
  -       ,   -
      MySQL.   -
 ,       ,  -
   . 
2.    MySQL  ,       (-
,  ,   Web-,     
..). 
  ,           
  ,         -
     ,     , 
    . 
 ,   ,     -
  ,   ,  ,   
   .    -
        . 
,    ,       
MySQL  3.22.27.      MySQL  -
 .         
        
MySQL   http://mysql.com. 
    MySQL 
 ,    MySQL      -
    (;),   MySQL  ,    
.          .  
     
 ,  ,       .  
    ,    . -
     ,  MySQL   -
.      : 
grant select 
-> 
 ,  MySQL    .   ,    
   ,        -
   Enter. 
   ,  SQL-   ,    
     .        -
. 

170  2.  MySQL 
   MySQL 
    MySQL         
 : 
> -h 
    -,     
    . 
 mysql   MySQL.    , -
     MySQL. 
 -h    ,    -
       MySQL.      
  ,     MySQL,   ,   
  hostname,   .   ,   hostname 
   ,     MySQL. 
 -     ,    
 .     ,    -
 ,       . 
  MySQL       , 
      root    ,    
     .    ,  root 
  ,     . 
 MySQL   ,    , 
  ,     . 
 -    ,       
.     ,   ,   -
  ,   . 
       root        -
,         
.     root   . 
      .  MySQL   -
.        .     -
 ,             
 . 
         -
: 
Enter password: **** 
(   ,   ,  MySQL-   - . 
    mysql.) 
  .    ,   -
  : 
Welcome to the MySQL monitor. Commands end with or \g. 
Your MySQL connection id is 9 to server version: 
Type ' 
mysql> 
       , ,   -
  mysql_install_db (  ),     
   root. 

 8.  Web-  
   ,      . 
     MySQL   , ..  
    . 
  ,     . 
       ,      -
.         "   
".         -
,        . (  ,  
 !) 
      
   MySQL      -
.         .   -
      books. 
   
   .     MySQL: 
mysql> create database 
 dbname    ,   .   
       books. 
 .     : 
Query OK, row affected (0.06 sec) 
 ,     .     , 
,        .     
MySQL,        . 
   
 MySQL    .  root  -
       . 
 ,     ,   -
   .       ,   MySQL (-
,   ,      UNIX  NT). To   
    root. ,        
   MySQL, ,       
      ,    -
   . 
  Web-         -
 Web-. 
 : "   ?" --    . 
    MySQL 
    MySQL      
. 
        -
   .       -
  . 

1 /  2.  MySQL 
    MySQL,    , -
 ,      ,    . 
   
        
  . 
 ,    ,     . 
   : 
 ( )     , 
    . 
   MySQL  ,      . ,  
   Web,       , -
    root. ,     
,        -
      . 
  
 GRANT  REVOKE   ,    -
    MySQL    .   : 
  
   
  
  
   ,      . 
   GRANT       
.    GRANT   : 
GRANT privileges [columns] 
ON 
TO [IDENTIFIED BY ] 
[WITH GRANT OPTION] 
,    ,  .  
     . 
, privileges (),     -
 ,    MySQL.    . 
 columns () .     , 
     .     
 ,      . 
 item ()      ,   -
  . 
    *.*,       .  
    .      
  *. 
           * 
   
       -
   columns.       

 8.  Web-  / 
:  ,   , .    
   -   ,  
      "    ". 
      ,   
    MySQL. ,       -
 ,      .  MySQL -
      ,     ,   -
, , (     
 ,           
 .  ,   ,   -
 ,           -
   . 
 password    ,   . -
    .     
 ,  ,       .  -
         .   
            
. 
 WITH GRANT OPTION,  ,     
  . 
     ,    
      : mysql.db, 
mysql.tables_priv        
  .    GRANT,  -
   .       
    
 MySQL     : ,  -
   ; ,    -
,    .     
 ,   ,     -  
,       . 
        ,  -
  .     mysql     ,  
,        ,   
.. (     11.) 
         
SQL     .    SQL   -
 .     ,    .  
  .   Applies To ( )  -
,       . 
        -
  .  ALTER      
 , ,   ,   
    .       -
   .      
ALTER,    ,      . 

174  2.  MySQL 
 8.1    
 
SELECT 
INSERT 
UPDATE 
DELETE 
INDEX 
ALTER 
CREATE 
DROP 
  
,  
,  
 
 
 
 
 
 
 , 
 
 
    ()  
. 
      
. 
     
  . 
    
  . 
      
 . 
    
 ,  , 
       
  . 
      
 .   GRANT  
    ,  
   (CREATE)     
  ,    
 . 
      
. 
 ,   . 8.1,    
REFERENCES, ,      ,   
GRANT,     WITH GRANT OPTION. 
 . 8.2  ,  . 
 8.2    
  
RELOAD        
, ,    . 
SHUTDOWN     MySQL. 
PROCESS        . 
FILE         
      ,     
,   .       
   RELOAD, SHUTDOWN  PROCESS. 
  FILE    .     -
,   ,       , 
   .   ,     -
  ,   MySQL   ,    
     .      -
     . 
   ,    . 8.3. 

 8.  Web-  1 / 
 8.3   
ALL   ,   . 8.1  8.2. 
 ALL    ALL PRIVILEGES. 
USAGE He   .    
 ,      
   - .  ,    
    - . 
 REVOKE 
  GRANT   REVOKE.    
        GRANT: 
REVOKE privileges 
ON 
FROM 
   WITH GRANT OPTION,     -
 : 
REVOKE GRANT OPTION 
ON item 
FROM 
   GRANT  REVOKE 
    : 
grant all 
-> on * 
-> to fred identified by 
-> with grant option; 
    Fred        
      . 
      ,    : 
revoke all 
-> on * 
-> from fred; 
      : 
grant usage 
-> on 
-> to sally identified by 
   (Sally),   -        
 : 
mysql> grant select, insert, update, delete, index, alter, drop 
-> on 
-> to sally; 
,       Sally. 
    ,   -    ,   
 : 

176  2.  MySQL 
revoke alter, create, drop 
-> on * 
-> from sally; 
,        ,    
   : 
revoke all 
-> on * 
-> 
     Web 
  PHP-  MySQL   .   
      :    -
  ? 
         
  : SELECT, INSERT, DELETE  UPDATE.   
 : 
grant select, insert, update 
-> on 
-> to identified by 
He   !  , ,   . 
    Web-,  ,    
        ,  -
  .            
  (   ..)    Web-  
MySQL (   ).    . -
       : 
mysql> grant select, insert, update, delete, index, create, drop 
-> on 
-> to bookorama identified by 
      . 
    root 
  MySQL ,  quit.       
  Web  ,     . 
    
     ,        -
 MySQL         
   ,        Web-. 
        ,   -
 .   , : 
mysql> use 
dbname     . 
     use,         
 : 
dbname -h hostname -u -p 

 8.  Web-  
      books: 
use 
    MySQL    : 
Database changed 
        , MySQL  -
  : 
ERROR 1046: No Database Selected 
    
       .    -
 SQL- CREATE TABLE.    CREATE TABLE -
  : 
TABLE 
 tablename     ,  -
 , a columns        . 
    ,     . 
  
Name, Address, City) 
Orders(OrderID. Amount, Date) 
Author, Title, Price) 
Order ISBN. Quantity) 
Reviews) 
  SQL-    ,   -
,    books  .       
CD-ROM   
SQL-     : 
> -h host bookorama books -p < 
       ,  
,    SQL-     -
. 
 8.1 bookorama.sql - SQL-    
create table customers 
( customerid int unsigned not null auto_increment primary key, 
name (30) not 
address not null, 
city not null 
create table orders 
( int unsigned not null auto_increment primary key, 
customerid int unsigned not null, 
amount 
date date not null 

178  2.  MySQL 
create table books 
( isbn char(13) not null primary key, 
author 
title 
price 
create table 
( int unsigned not null, 
isbn (13) not 
quantity tinyint unsigned, 
primary key 
create table 
( 
isbn (13) not null primary key, 
review 
       CREATE TABLE.  -
,     ,  ,    
.        .  -
    . 
    
NOT NULL ,          -
.  NOT NULL  ,     (NULL). 
   MySQL,   -
   .          
, MySQL     .  
      ,    
.          .   
AUTO_INCREMENT   . 
PRIMARY KEY    ,     -
   .       . MySQL 
   . ,  ,    
   customers,  AUTO_INCREMENT  . -
      ,  
 PRIMARY KEY      ,   
        .  -
   PRIMARY KEY     order_items.  
      . 
UNSIGNED    ,       
,  . 
    
  : 
create table customers 
( customerid int unsigned not null primary key, 
name not 
address not null, 
city not null 

 8.  Web-  
         -
. 
  customers,    ,   . , 
   ,   .  
 ,      (  int),  
unsigned.  ,      MySQL  
       . 
       .    
 char.     .    , 
, ,    30 . 
      30   ,     
  .     MySQL   
   .     
varchar,      (  ).  -
,     varchar   ,  
char  . 
  ,     ,    
  . 
 ,     NOT NULL.   -
,        . 
         
    .    
orders: 
create table orders 
( orderid int unsigned not null auto_increment primary key, 
customerid int unsigned not 
amount 
date date not null 
 amount      ( float).   
           
  .         , 
       (6)   -
    . 
 date    date. 
   ,      NOT NULL,  
amount. ?      ,     -
 orders,          
.        ,    -
  NULL. 
  books   : 
create table books 
( isbn not null primary key, 
author 
title 
price 
       ,    ISBN 
   .    NULL,    

 U  2.  MySQL 
    ISBN,     ,   . 
       -
: 
create table 
( orderid int unsigned not 
isbn not 
quantity tinyint unsigned, 
primary key (orderid, 
      TINYINT UNSIGNED; 
      0  255. 
   ,       
    ,      
 . 
 ,   
create table 
( 
isbn not null primary key, 
review text 
    ,      .  -
   , , .    -
 ,    . 
      ,     
    ,       .   -
     . 
      SHOW  DESCRIBE 
   MySQL       books.    
 , : 
mysql> show tables; 
MySQL     : 
I Tables in books | 
book_reviews 
books 
customers 
orders 
-------------------
5 rows in set (0.06 sec) 
 show        : 
mysql> show 
 DESCRIBE       
 , , books: 
describe books; 

 8.  Web-  1  1 
MySQL  ,      : 
I Field |  | Null | Key | Default | Extra | 
I | (13) | I PRI | | | 
| author | | YES | | NULL | | 
I title | | YES | | NOLL | | 
I price | | YES | | NULL | | 
4 rows in set (0.05 sec) 
  ,   ,    -
,        . 
 MySQL 
    MySQL   , , -
 (    )   (     ). 
   MySQL    ,    -
.        ,    -
           () -
      ,        
    (, ,  UNIX),    (Windows). 
           
   SQL-     . 
 ,    ,  ,  , -
    .       
mysqladmin: 
variables 
      . 8.4.  
       ASCII(O)  
ASCII(255) ( ,   ,      -
). 
 8.4  MySQL 
.  
     
  64  ,     ,     
 ,    / 
 64  ,     ,     
 ,    /  . 
 64   
 255   
    . 
  MySQL 3.23.6      
    ;        -
   ,        ( 
        (~)    ). 
: 
create database 

182  2.  MySQL 
   MySQL ( 3.23.6)  ,    -
 . 
       ,      
. ,         , 
     . ,       , 
         . 
   
 MySQL     : ,     -
.        .   -
    ,        -
   
      .   , 
   ,    . 
          -
   .       
     .       -
,     .   255. 
         . 
 
      ,     -
.           -
 .        D.  , 
    D  30,  (..   
             
 ),    . 
     UNSIGNED,     8.1. 
      ZEROFILL.    
     . 
    . 8.5.  ,   -
     ,      (  ). 
 8.5    
   
() 
TINYINT [ () ] 128 1     
 
SMALLINT [ () ] 2    
 
[ () ] 3     
 
INT [ () ] 4    
 
INTEGER [ () ]  INT 
BIGINT [ () ] 8    
 - 1 

 8.  Web-  183 
       . 8.6. 
 8.6     
   
FLOAT (precision) 
FLOAT [ (, D) ] 
DOUBLE [ (M, D) ] 
 precision  
() 
3.402823466+38 
8 
+308 
-308 
DOUBLE 
PRECISION [ (, D) ] 
REAL [ D) ] 
DECIMAL [ (M[ , 
NUMERIC [ (M, D) ] 
 M+2 
 
   
   
   
  . 
    
 . 
 FLOAT(4),  
    
   
 . 
    
 . 
FLOAT(8),  
    
   
 . 
 DOUBLE [ (M, D) ]. 
 DOUBLE [ (M, D) ]. 
   , 
  char. 
   , 
 . 
 DECIMAL. 
    
MySQL       ,  
  . 8.7.          , 
  .        
        , 
   ,      .   -
   . 
 8.7      
 
DATE 
TIME 
DATETIME 
  
-838:59:59 
838:59:59 
00:00:00 
23:59:59 
.    YYYY-MM-DD 
.    HH:MM:SS (::). 
 ,    , 
  - . 
  .    
YYYY-MM-DDHH:MM:SS 

 4  2.  MySQL 
 
TIMESTAMP [()] 
YEAR [ (2|4) ] 
00:00:00 
- 
 
 2037  
70-69 
1901-2155 
 
 ,     . 
      
(.  . 8.8). 
      UNIX. 
.   -  
.   ,  ,   
. 
 8.8       TIMESTAMP. 
 8.8     
 
TIMESTAMP YYYYMMDDHHMMSS 
TIMESTAMP YYYYMMDDHHMMSS 
TIMESTAMP YYMMDDHHMMSS 
TIMESTAMP YYMMDDHHMM 
TIMESTAMP (8) YYYYMMDD 
TIMESTAMP (6) YYMMDD 
TIMESTAMP (4) YYMM 
TIMESTAMP (2) YY 
  
     .      -
,      .   CHAR ( 
  )  (   ).  
    .    CHAR   -
   ,    ,      
   VARCHAR     . ( , 
 MySQL        CHAR    
  VARCHAR   .)   ,    
    ,       
     TEXT  BLOB.     . -
        ,    
 . BLOB  binary large object (  )  -
   ,      . 
   TEXT  BLOB ,   ,  TEXT 
  , a BLOB  .      -
  ,     ,    
 
       SET  ENUM.  SET -
  ,  ,       
   .     -
   .        64 -
. 

 8.  Web-  1 5 
  .      SET,  -
             
NULL,         65535. 
 . 8.9, 8.10      .  8.9 -
   . 
 8.9   
 ,  
[NATIONAL]  1  255      
CHAR (M)   1  255.   NATIONAL 
[BINARY]   ,     
,   .  MySQL 
    ,   
   ,    
 ANSI- SQL.   BINARY 
,     
   . (  
     
.) 
[NATIONAL]  1  255   ,   , 
VARCHAR ()     VARCHAR . 
[BINARY] 
 8.10   TEXT  BLOB.    TEXT  
      ,     
 . 
 8.10  TEXT  BLOB 
   
( ) 
(.. 255)   BLOB 
TINYTEXT (.. 255)   TEXT 
BLOB (.. 65535)   BLOB 
TEXT (.. 65535)   TEXT 
(.. 16777215)   BLOB 
MEDIUMTEXT (.. 16777215)   TEXT 
LONGBLOB (.. 4294967295)   BLOB 
LONGTEXT (.. 4294967295)   TEXT 
   ENUM  SET. 

186  2.  MySQL 
 8.11   
 
 
    
ENUM 65535      
    
  NULL. 
SET 64      
    
NULL. 
  
         -
  MySQL,     http://www.mysql.com/. 
  
  ,   , ,  , , -
,       .    
 ,     ,    ,   -
    . 

   
 MySQL 
     -
  (SQL)       
 .      
,  ,    ,   
   . 
,   : 
   SQL? 
      
      
   
      
     
      
   
   ,    SQL   
 . 
       Book-O-Rama, 
   ,     
       -
.       8. 
  SQL? 
SQL   Structured Query Language 
(  ).   -
       -
   (). SQL   
        .  
       MySQL, 
Oracle, PostgreSQL, Sybase,   Microsoft SQL Server. 

188  2.  MySQL 
 SQL   ANSI,     MySQL   
. ,   ,     - .  -
 MySQL    . 
       (Data Definition Languages, 
DDL),      ,    -
  (Data Manipulation Languages, DML),     -
. SQL    ,   .   8  ,  -
   SQL ( DDL),       . DDL 
      . 
 DML   SQL  ,     
       . 
     
       ,    -
 - .      
 SQL INSERT. 
 ,    ,  ,   , -
  ,   .     -
  -    ,     
      .  INSERT  -
        . 
   INSERT  : 
INSERT [INTO] table ...)] 
. . 
,      Customers   
 : 
insert into customers values 
(NULL, "Julie Smith", "25 Oak "Airport 
 ,   table   ,   -
  , a values   .    -
    .  MySQL       
      . (     
.)       . 
  INSERT    . 
     ,    -
  .      ,    
             -
,    . : 
insert into customers (name, city) values 
("Melissa Jones", Nar Goon 
  ,   -     - 
     .    
,    : 
insert into customers 
set 
Adderley Avenue", 

 9.     MySQL 
, , , ,  Julie Smith,    
  (NULL),        
 .     , customerid   
   Customers,      .   
,      ,   -
       , MySQL   
       .  
 . 
       .     
  ,  . 
   ,    .  
  INSERT      
. ,  ,    
 CD-ROM,        
9.1. 
 9.1.  SQL-    
use 
insert into customers values 
(NULL, "Julie "25 Oak "Airport 
(NULL, "Alan "1/47 Haines Avenue", "Box 
(NULL, "Michelle Arthur", "357 North 
insert into orders values 
(NULL, 3, 69.98, 
(NULL, 49.99, 
(NULL, 2, 74.98, 
3, 24.99, 
insert into books values 
"Michael "Java 2 for Developers", 
, 
("0-672-31745-1", "Thomas "Installing Debian 24.99), 
et "Sams Teach Yourself GIMP in 
24 
"Thomas OpenLinux System 
Administration 
insert into order_items values 
(1, 2) 
(2, "0-672-31769-9", 1) 
(3, 1) 
(3, 1) 
(4, 3) 
insert into book_reviews values 
"Morgan's book is clearly written and goes well beyond 
most of the basic Java books out 
  ,    MySQL  : 
>mysql -h host -u -p < 
     
  MySQL   SELECT.      
,    ,     . -
 SELECT      . 

190  2.  MySQL 
    : 
SELECT 
FROM tables 
[ WHERE ] 
[ GROUP BY ] 
[ ] 
[ ORDER ] 
[ LIMIT ] 
  .        
,   ,      -
   .     . ( ,  -
     MySQL.      -
  .)      name () 
 city ()  Customers: 
select city 
customers 
        : 
| name 
Julie Smith 
Alan Nong 
Michelle Arthur 
Melissa Jones 
Michael Archer 
. 
city 
Airport West 
Box Hill 
Yarraville 
Nar Nar Goon North 
 ,       name  city   -
  Customers.         
Customers. 
    ,   ,   -
       select.  ,    -
 .         *, 
          ( 
). ,          
 : 
select * 
     : 
I 
._ 
1 
2 
3 
3 
4 
| 
0-672-31697-8 
0-672-31769-9 
0-672-31769-9 
0-672-31509-2 
0-672-31745-1 
quantity 
2 
1 
1 
1 
3 

 9.     MySQL 1 
     
       ,    
.      where. , 
select * 
orders 
where = 3 
     ,      customerid,  3. 
 : 
I orderid | customerid | amount | date 
I 
69.98 
24.99 
0000-00-00 
0000-00-00 
 where     .   
    customerid,  3.    -
       ,      
,      ,   ,   . 
  , MySQL      -
 .     where   . 9.1. 
 ,     ,    -, -
  ,     MySQL. 
 9.1       WHERE 
 
( ) 
 
 
   
   
  
!=   
IS NOT NULL 
IS NULL 
BETWEEN 
IN 
NOT IN 
  quantity !=0 
    
   
  0  60.00 
  
"") 
   
("Carlton", "") 
customerid=3 ,     
 
,     
 
,    
  
,     
     
,     
     
,      
,     
,      
,    
     
  
,    
   
,    
    

192 2.  MySQL 
 
LIKE 
NOT LIKE 
REGEXP 
 
( ) 
 
 
 
 
 
name like 
("Fred 
name not like 
("Fred 
name regexp 
 
   
,   
  SQL 
,    
  
,   
   
      LIKE  REGEXP.   -
 . 
LIKE     SQL.     
   % ( )      -
   _ ( )      -
.  MySQL     . , -
  ,    
  REGEXP     . 
MySQL      POSIX.  REGEXP  
    .   POSIX  
   .        4. 
    ,    AND  
OR. , 
select * 
from orders 
customerid = 3 or customer = 4 
    
           -
   . ,   ,    
    ,    Customers  Orders. 
  ,    ,      
Order_Items. 
     ,      
.        ,    -
   7. 
     SQL   , -
 .        ,  
   . , ,  , 
    Julie Smith,      
Customers     Julie,     Orders   
,   CustomerlD. 
       ,     
       SQL.  MySQL   
  ,       . 

 9.     MySQL 
    
   Julie Smith,      : 
select 
from customers, orders 
where = 
and = 
   : 
I orderid | amount | date | 
+ 
I 2 | 49.9 9 | 
    . 
-,          , 
    . 
    ,       
    INNER JOIN  CROSS JOIN.   
        . 
 : "        .   
           -
,   ,     ".  ,  
,      Customers    
 Orders   ,     . 
      .  ,   , 
    , ..       -
,   . 
      WHERE  .  
   ,  ,    -
   .        -
: 
= 
  MySQL        
Customerid   Customers   Orders. 
    ,       -
   (equi-join). 
    ,     -
    . ,  
  customerid   Customers, a    customerid 
  Orders. 
  ,    ,  -
,          . 
           
 .       
     database.table.column -
,     
= 
7 216 

194  2. MySQL 
  ,          
  .      ,  
     . MySQL   ,  - 
       .   ,  -
      ,       
= 
 name     customers,   -
 ,  ,  -, . 
     
       .   -
     ,   .   
       ,   . 
,   ,       Java (, 
  ,         Java),  
       . 
   , ,   ,  , 
     Java.   Customers  
  Orders,      .   
Orders   Order_Items,  orderid.  Order_Items    Books 
  ,   ISBN.      -
,     Java       
 ,   -   . 
  ,      : 
select 
customers, orders, books 
where = 
and = 
and = 
and like 
    : 
I name 
+ 
I Michelle Arthur 
 ,        ,   
      ,     
.        ,  
,        -
 .         , 
  .        , 
      ,  ,       , 
  . 
   
     MySQL    . 
      ,    -
  .     ,    

 9.     MySQL 
  ,   ,      
,  ,    . 
        MySQL   -
  ,        -
        ,   -
  ,    . 
  : 
select 
customers left join orders 
on = 
  SQL       Customers  
Orders.        ;  
     ON  SQL. 
  : 
I customerid | name orderid | 
1 
2 
3 
3 
4 
5 
Julie Smith 
Hong 
Michelle Arthur 
Michelle Arthur 
Melissa Jones 
Michael Archer 
2 
3 
1 
4 
NOLL 
NULL 
 ,    Melissa Jones  Michael Archer  -
 orderid,   orderid   NULL. 
     ,    -
,   ,     NULL    
   (  , orderid),     
     NULL: 
select 
from customers left join orders 
using (customerid) 
where is null; 
  : 
I customerid | name 
| Melissa Jones | 
| Michael Archer | 
,     ,      -
    .    -
   ON,     ,   USING,    -
.  USING      ,  
  ,      ,   -
    . 

196  2.  MySQL 
   :  
   ,        -
 .     (aliase).     -
  ,      .   
,  ,     . ,   -
  ,   ,    
: 
select 
from customers as orders as as books as b 
where = 
and = 
and = 
and like 
 ,    ,   -
 as,   .  ,    -
,       ,    . 
         . 
      ,     .   
         ,      -
  .    ,    , , 
    ,        
(Customers)   : 
select 
customers as customers as c2 
where cl.city = 
and name != c2. name 
  ,   Customers        -
, cl  2,      City.  , cl.name != 
  ,       -
   . 
    
 . 9.2    .     
,     . 
 9.2    MySQL 
 
        .   
        
  WHERE. 
   . 
       
   CROSS JOIN   
 . 
    .    
   INNER   WHERE 
  .    
    WHERE. 

 9.     MySQL \ 
 
   
   
 
    =   
     .  SQL   
   WHERE. 
       
    NULL.  SQL 
    LEFT JOIN.  
   .   
 RIGHT JOIN. 
     
 ,   ,     -
,     ORDER BY  SELECT.  -
       . 
 ORDER BY      ,  
  SELECT. , 
select name, address 
from customers 
order by name 
           -
: 
 
Alan Hong 
Julie Smith 
Melissa Jones 
Michael Archer 
Michelle Arthur 
1/47 Haines Avenue 
25 Oak Street 
12 Adderley Avenue 
357 North Road 
i 
! 
( ,    ,       -
,     .       
(  ), ,         .) 
       (   z   -
  ).      ASC ( 
ascending): 
select name, address 
from customers 
order name 
          
  DESC ( descending): 
select name, address 
from customers 
order by name 
     .    -
  ,      (, 3    
  ). 

198  2.  MySQL 
    
  ,      ,  
   -   ,     
 .  MySQL    ,   
     . 
         ,    
   . 
      . 9.3. 
9.3  MySQL 
  
AVG ()      . 
COUNT ()       () 
   .      
 DISTINCT,       
.   COUNT     
    . 
()    . 
 ()    . 
STD ()     . 
STDDEV ()  . 
SUM ()    . 
   ,    .  -
     : 
select avg (amount) 
   : 
avg (amount) 
    ,   -
 GROUP BY.        , -
,   ,     ,     -
  : 
select avg (amount) 
from orders 
group 
   GROUP BY     -
   .       
  ,          
 (  ,  customerid) 

 9.     MySQL \   
I | | 
I I 49.990002 | 
! 2 | 74.980003 | 
I 3 | 47.485002 | 
,         -
:       GROUP BY 
 ANSI SQL,   SELECT     -
  ,    BY.   -
    GROUP BY,       
SELECT. 
   MySQL     , -
  ,        
 SELECT. 
          -
     HAVING.    
  GROUP BY    WHERE,     -
  . 
   , ,  ,   
        $50,   -
 : 
select customerid, avg 
orders 
group by 
having avg (amount) > 
,  HAVING   .    -
 : 
I customerid | | 
+ 
2 | 74.980003 | 
+ 
    
   SELECT,      
 Web-    LIMIT.    , -
    .   :  ,  
  ,   . 
    LIMIT: 
select name 
from customers 
limit 2, 3; 
   : "   ,  -
   ,    2".  ,    
  . 

  2.  MySQL 
     Web-.     , 
   ,           
 10 . 
     
 ,       ,   -
  . ,      -
   .   ,   UPDATE. 
     : 
UPDATE tablename 
SET 
[WHERE condition] 
[LIMIT number] 
        tablename,  
   column   expression. -
 WHERE UPDATE       -
,   LIMIT   ,   . 
   . 
        10%,   -
 UPDATE   WHERE: 
update books 
set 
     , ,   , -
   : 
update customers 
set address = Olsens 
where 
    
    ,     -
    .       ALTER 
TABLE.    : 
ALTER TABLE tablename alteration [, ...] 
 ANSI SQL   ALTER TABLE     -
,    MySQL   .   
     . 
 ,   ALTER TABLE,   
. 9.4. 

 9.     MySQL 
 9.4   
ADD [COLUMN] 
[FIRST | AFTER column ] 
ADD [COLUMN] 
...) 
ADD INDEX [index] (column, ...) 
ADD PRIMARY KEY (column, ...) 
ADD UNIQUE [index] (column, ...) 
ALTER [COLUMN] column 
DEFAULT value \ DROP 
CHANGE [COLUMN] 
column 
MODIFY [COLUMN] 
DROP [COLUMN] column 
DROP PRIMARY KEY 
DROP INDEX index 
RENAME[AS] 
  ALTER TABLE 
 
      ( 
  ,    ). 
 ,  
  ,   ,     
 CREATE. 
       
. 
     () 
. 
   ()  
 . 
      
() . 
      
 . 
    column ,  
   .   
    , 
    . 
  CHANGE.    
 ,   . 
  . 
   ( 
  . 
 . 
     ALTER TABLE. 
  ,    : -  " 
",      . ,    
Customers        30 .    -
,           -
   .    ,    , 
          45 . 
alter table customers 
modify name char(45) not null; 
       . -
,         ,   
   ,    ,   
 .   Orders    : 
alter table orders 
add tax after amount; 
 -    .  ,  
   : 
alter table orders 
drop 

  2.  MySQL 
     
      .     -
 DELETE,    : 
DELETE FROM table 
[WHERE condition] [LIMIT number] 
   
DELETE FROM 
     ,    !   
 -        -
 WHERE.   ,  -      -
       : 
delete from customers 
where 
 LIMIT    . 
  
     .      
 DROP TABLE.   : 
TABLE 
           ,    
  . 
    
        !    
 - DROP DATABASE: 
DROP DATABASE database; 
    , ,     .  -
  ,       ,    . 
  
      SQL,       
    MySQL.      ,  -
 MySQL  ,        Web.  , -
      MySQL. 
      SQL,   , 
   ANSI SQL,   : 
  MySQL    ANSI SQL   Web-
 MySQL: 
  
  10  ,        Web. 

10 
   
 MySQL  
Web    
        -
     . 
      2,  
 ,      , -
       
  Web-. ,   MySQL 
   ,    -
      Web-. 
    ,      
  Web,  .  , 
       ,   -
    . 
    : 
    Web-  
        
 Web 
   
       
    
      
    
     
       
     
    PHP-MySQL 
   PHP-  

204  2.  MySQL 
   Web-  
  7     ,    Web- -
.     : 
1. Web-   HTTP-  Web-. -
,     ,   
,  HTML-.      -
 results.php. 
2. Web-    results.php,       
  
3.      .    -
       ( ).   
  MySQL-    . 
4.  MySQL     ,     
 ( )   . 
5.     ,      
    HTML.      
HTML  Web-. 
6. Web-  HTML  ,    
   . 
     MySQL,     , -
   .    .   HTML-
.        
 10.1 search.html      Book-O-Rama 
<head> 
Catalog Search</title> 
</head> 
<body> 
<hl>Book-0-Rama Catalog Search</hl> 
Choose Search 
<select 
<option 
</select> 
<br> 
Enter Search 
<br> 
<input 
</body> 
,    HTML-.  . 10.1   -
 . 

 10.     MySQL  Web    
html 
 10.1 
  
 
   
  , 
   
I 
Book-O-Rama Catalog Search 
Search Type: 
j 
Enter Search Term: 
       Search,   
results.php.      10.2.     ,  
      . 
 10.2 results.php -       MySQL  
     
<head> 
Search Results</title> 
</head> 
<body> 
Search Results</hl> 
if 
echo "You have not entered search details. Please go back and 
= 
= 
@ = 
if 
echo "Error: Could not connect to database. Please try again 
exit; 
= "select * from books where like 
$result = 
= 
echo of books found: 

206  2.  MySQL 
for $i $i++) 
$row = 
echo ($i+l) . Title: 
echo 
echo 
echo htmlspecialchars 
echo 
echo htmlspecialchars ] 
echo 
echo htmlspecialchars 
echo 
 10.2       -
 . 
 10.2 
    
   Java  
  
results.php  
 
Book-O-Rama Search Results 
Number of books found: 1 
1. Title: 2 
Author: Michael Morgan 
ISBN: 
Price: 34.99 
    
    Web 
  ,        Web,  
  : 
1.    ,   . 
2.      . 
3.     . 
4.  . 
5.   . 
      results.php,        
. 

 10.     MySQL  Web   
      
        ,   
  .      -
  ( ). 
   ,       . -
,    ,       -
.     ,   ,   
  ,      ,    
 ,     
if | | 
{ 
echo "You have not entered search details. Please go back and 
exit; 
} 
      ,     . 
          
 SELECT.   ,    .  
,        . Amazon -
   ,     -
.  ,        , 
    . 
   ,    ,  
      .  , -
, ,   4      -
 ,  ,     MySQL,  -
        
        addslashes(): 
= addslashes 
 ,   ,  stripslashesQ.    
  ,     .    
 .   Web-      ,  
     ,  ,  ,  
  .     ,    
addslashes(),   ,        
 ,    . 
    ,   HTML 
  .      (&),  "-
" (<), "" (>),       -
        
  . 
  
    MySQL     : 
@ = 

 2.  MySQL 
       mysql_pconnect()  -
 : 
int ( [string host ] , 
[string user] , [string password] ) 
    (host),     MySQL,  
 (user),    ,   (password).     -
      ,   -
       ,  ,  -
  ,   . 
          ( -
    ),       false. 
   ,        
.    : 
if 
{ 
echo "Error: Could not connect to Please try again 
exit; 
> 
 ,    ,   -
     mysql_connect().     ,  
mysql_connect()      . 
     ,     
      mysql_close().   
    ,   ,   mysql_close()  
 . 
  ,    .  :    
    ,   . 
         
,   ,      . 
 ,     .    ,   
 . 
     CGI,      
   . (       -
    ,     . ,   -
,     .) 
,     MySQL,   -
, .    max_connections.   (  
   Apache MaxClients)      
  ,        -
  . 
    ,   . -
  MaxClients  Apache,    httpd.conf.  
 MySQL      my.conf. 
    ,     
       , , ,  -
     Apache.     -
,   ,    .  

 10.     MySQL  Web   PHP 
 Apache   150 , a MySQL   100.   -
     .     -
     Web-   , ,  
      . 
   
  MySQL   ,  ,   -
 : 
use 
        Web.    --
 
    : 
int database, [int ) 
        database.   
    ,      -
 (   $db), ,    ,   -
  .     ,  -
  ,     mysql_connect(). 
     
  ,    -
    : 
= "select * from books like 
     ,   
 ,    ,   
 ,    like,     equal   
   . 
 
 ,  ,  MySQL,      
 ,    ,      MySQL. 
   : 
= ; 
  : 
int query, [int 
   ,    ;   -
       (   $db).    , 
    .   ,  -
    ,    

  2.  MySQL 
,      
  : 
int database, string query, 
[int ) 
   ,      ,   -
  .  -     
 
     (   -
 )      false   .  -
   ( ,      $result),     
 . 
   
       -
.        ,  -
,    ,   . 
     : mysql_numrows()  
   ,   . 
     : 
$num_results = 
  ,      .  
 ,   : 
for $i 
{ 
//  
} 
      mysql_fetch_array().    
,   .         
      ,      
    : 
$row = 
  ,       -
  : 
echo 
echo ) 
  ,   ,  "" -
,     . 
       -
.       , 
 
$row = 
        
 .. 

 10.     MySQL  Web   
   mysql_fetch_object()     : 
$row = 
         
$row->author  .. 
        .    
 ,       -
 ( 0     1)   , : 
$row = 
       (   "title"    
  (  He   
   . 
    ,  
      . 
    
     : 
     ,     
   . 
      
       .  
      ,     . 
     SELECT   INSERT. 
    ,       .  . 10.3 
  HTML-       . 
HTML-      10.3. 
 10.3 
  
    
 ,  
   
 
- New Book 
Entry 
ISBN 
Author 
Price 

212  2.  MySQL 
10.3  HTML-     
<head> 
- Book 
- Book 
border=0> 
<tr> 
<td>ISBN</td> 
<tdXinput name=isbn 
</tr> 
<tr> 
<td> <input maxlength=30 size=30Xbr></td> 
</tr> 
<tr> 
<td> size=30Xbr></td> 
</tr> 
<tr> 
$</td> 
maxlength=7 size=7XbrX/td> 
</tr> 
<td 
</tr> 
</table> 
</body> 
       , -
 ,       
   .       10.4. 
 10.4 insert_book.php         
<head> 
Book Entry 
</head> 
<body> 
Book Entry 
<? 
if I I ! $price) 
{ 
echo "You have not entered all the required 
go back and try 
exit; 
} 
$isbn = 
$author = 
$title = 
$price = 
@ 

 10.     MySQL  Web    
if 
{ 
echo "Error: Could not connect to database. Please try again 
= "insert into books values 
$result = 
if ($result) 
echo book inserted into 
</body> 
         . 10.4. 
    ,        
    .  ,      
     addslashes ()     
: 
$isbn = 
$author = 
$title = 
$price = 
          ,  -
     .       
       .  -
 doubleval()   1.         -
,       . 
     ,   -
 .     INSERT. 
"insert into books values 
' ' 
$result = 
     
 10.4 
  
    
, 
  . 
Book Entry 
Results 
1 book inserted into database, 

 2.  MySQL 
    INSERT  SELECT   -
 
echo book into 
       
 ,    SELECT.   , -
   , , INSERT, DELETE, UPDATE,  -
 
      MySQL  .   
   ,   . 
   PHP-MySQL 
     PHP-MySQL. 
  
      ,    
,      : 
int 
    : 
   ,  . ,   -
      . 
     
     MySQL  PHP-   
      
   : 
int database, [int 
int database, [int ) 
       .   , 
   .      
 .       true,     
 false. 
  PHP-  
   ,      
   ,  Oracle, Microsoft SQL Server,  
PostgreSQL. 
            
   .     ,     
  ,       MySQL,  -
        . 
    ,     -
,   ,      ODBC. 

 10.     MySQL  Web   PHP 
ODBC           -
    .  ODBC   -
 ,       :  -
 ,      
. 
  PHP-,      ,  
Metabase,             
 . 
  
   MySQL       
     MySQL. 
  ODBC   : 
  Metabase   Web-: 
  
         
MySQL         . 

11 
 
 MySQL 
    -
  MySQL: ,  
 . 
 ,   : 
     
     MySQL 
     
 
       
 
    
    
    
,   8,    
    .   -
  GRANT.    -
   MySQL,   -
,    GRANT   . 
 GRANT      -
  ,   -
         
. ,     
 ,        
 mysql. 
,   GRANT   
MySQL     
    mysql , -
      : 
use 

 11,  MySQL / 
     , : 
show 
 . 
    : 
Tables in mysql 
host 
user 
        .    
 .      ,      -
,  ,      .   - 
   :  ,   -
,     ,   , ,   
  ,    . 
 user ()   ,   -
    MySQL      . 
 db  host ,        -
.         , 
a columns_priv        . 
 user 
        ,  
:        MySQL     
  -   , .. ,  -
      . 
 describe    . 
  user   . 
 11.1      
 
Host 
User 
Password 
Select_priv 
lnsert_priv 
Update_priv 
Delete_priv 
Create_priv 
Drop_priv 
 
enum('NYY') 

218  2.  MySQL 
  
Reload_priv 
File_priv 
lndex_priv 
Alter_priv 
        , -
         .  -
    ,      , -
  . 
    (   ,    
)    ,    
GRANT (.  8). ,     
  SELECT. 
    ,     
 Y.   ,      ,  -
  N. 
 ,    user,  , ..  
       (    
  ,  Y,   ,    -
     N.    -
     ,        
. 
  host 
        -
 db  host. 
 db ,          
  .        
 . 
 host   db.      -
  ,     ,   db    
    . ,       
   host,      . 
  db  host , ,  . 11.2  11.3. 
 11.2   db    mysql 
  
Hosf 
Db char(64) 
User 

 11.   MySQL 
 
Select_priv 
Delete_priv 
Create_priv 
Grant_priv 
References_priv 
lndex_priv 
Alter_priv 
 11.3   host    
 
Host 
Db 
Select_priv 
Update_priv 
Delete_priv 
Create_priv 
Drop_priv 
Gran+_priv 
References_priv 
lndex_priv 
Alter_priv 
 
char(64) 
  
     , ,   
    .     db   , 
            
  . 
        user, 
db  host.      .  -
. 

  2,  MySQL 
 11.4   tables_priv    
  
Host 
Db char(64) 
User 
Grantor char(77) 
Timestamp 
Table_priv 
Column_priv 
 11.5     mysql 
 
Host char(60) 
Db 
User 
Table_name 
char(59) 
Timestamp 
 Grantor     ,  
   .  Timestamp     
      . 
:  MySQL    
MySQL      ,   
 ,      . 
1.  .    MySQL ,      
 ,     user,   . -
    ,   .    
 , ,    .    
       , .. %  
 " ".        
,   ,   
   , ,   .  -
   , ,      -
,         . 
2.  .         
, MySQL ,        
   .      -

 11.   MySQL 
 (     ,  db  host. 
     , MySQL   ,  
 ,  
 :     ? 
      GRANT  REVOKE  MySQL -
   . 
  ,    ,      , 
    .      , 
 MySQL  ,   . 
  ,   ,    -
  .  : 
PRIVILEGES; 
   MySQL (    ).  -
    . 
  : 
flush-privileges 
 
mysqladmin reload 
   . 
         -
  ;        
  use,         -
 . 
    MySQL 
  ,        
MySQL  Web-.        , -
       . 
MySQL      
    UNIX-  ,   MySQL-
 (mysqld)     ,  
       MySQL    -
      .    -
 ;       Web- Apache. ( 
,   " "  ,  
      .) 
       . ,  -
  (    )   -
  MySQL.         -
    
 , ,    MySQL  .   
     ,   
       3306.  ,   MySQL -
         . 

222  2.  MySQL 
 
  ,     (,  ) 
  ,      ,  
  . ,        , 
   ,  .   -
    . 
         ,  -
  ,      ,   .   
   : 
1.       -
 UNIX.   ,         ,  
. 
2.         , -
     .    ,  -
        , , dbconnect.php, 
     .     
 Web-      . 
,       a.inc      -
   Web-,      -
,   Web-,       
PHP-,       Web-. 
        .  MySQL -
   ,    Web-   -
 Web-   .   () ,  
MySQL-  MD5(). ,      
(INSERT)      SELECT (   
  ),     ,  -
,     . 
    ,     
   . 
  
  .  ,      MySQL 
    ?    -
 ,  .   ,   . 
  ,     PROCESS, FILE, 
SHUTDOWN  RELOAD ,  ,      
.  PROCESS    ,  , 
     ,   .  FILE -
         (, , 
/etc/password   UNIX). 
 GRANT    ,   -
       . 
         
     ,       .   -
 jane@localhost,  ,    jane    -
,         ,     jane,   

 11.  MySQL 
  .         
  . 
    ,    host IP- 
  .      ,    -
  DNS.   ,   MySQL   
resolve,         IP-  - 
. 
     mysqld      
  IP-,       . ( 
   ,    3.22.) 
 ,    ,     
     Web-.     
 ,          -
 . 
 Web 
    MySQL  Web  ,  
  . 
    ,      Web-- 
      ,  
   DROP, ALTER  CREATE. SELECT  -
    , a INSERT    .  -
     . 
 
      PHP-  
       .    . -
    ,    -  MySQL    
 .  ,      
,      .   -
       ,    addslashesl),  -
   . 
  ,   .   HTML-, -
      -   -
     .     
  . 
      ,   
    , ,        
  ,      SSL (Secure Sockets Layer -
  ).   SSL  . 
     
    ,  ,         
    ,  SHOW  DESCRIBE. 
    SHOW 
  
SHOW 
 ,       . 

  2.  MySQL 
 
show databases; 
    .     SHOW TABLES 
         : 
show tables 
 SHOW TABLES     ,  -
  . 
  ,      : 
show columns orders 
     ,  SHOW COLUMNS   
 .      
show columns 
     SHOW    -
  .  
show grants for 
    : 
 11.1  SHOW GRANTS. 
  GRANT       
 ,      ,  -
,  . 
 
 SHOW GRANTS   MySQL 3.23.4;      -
 ,    . 
    SHOW.     . 
 11.6  SHOW 
  
SHOW DATABASES     
[LIKE ]      
SHOW TABLES     ,  
[FROM ]   ,    
[LIKE  ]        
    . 
SHOW COLUMNS FROM        
[FROM ]  ,     . 
[LIKE  ]        . 
 SHOW COLUMNS   SHOW FIELDS. 

 11.   MySQL 
SHOW INDEX FROM 
[FROM ] 
SHOW STATUS 
[LIKE 
SHOW VARIABLES 
[LIKE 
SHOW [FULL] PROCESSLIST 
SHOW TABLE STATUS 
[FROM ] 
[LIKE 
SHOW GRANTS 
FOR 
 
      
       
  ,   . 
   SHOW KEYS. 
     , 
  , 
 LIKE      
, ,     
      
MySQL, ,  .  LIKE  
       
,   SHOW STATUS. 
      , 
..   .  
  ,    
,      
PROCESS,      
     ,   
  .    
   .  FULL   
 . 
     
  ,   ,   . 
     
.        
   
  GRANT,   
     
. 
      
  SHOW COLUMNS  DESCRIBE,  -
 DESCRIBE    Oracle.    : 
DESCRIBE 
          -
 ,   .       -
  . 
    EXPLAIN 
 EXPLAIN     .  : 
EXPLAIN 
      DESCRIBE  
 SHOW COLUMNS FROM . 
,       EXPLAIN  , 
 ,  MySQL      SELECT.  
     SELECT   explain. 
8 216 

226  2.  MySQL 
 EXPLAIN  ,    
          -
,  .       -
  ,   EXPLAIN  , , ,  
 .        
      MySQL, , ,    
.  , EXPLAIN     . 
,        -
      . 
explain 
select 
from books 
where = 
and = 
and = 
and like 
| | ALL | 
| | 
| | NULL | NOLL 
| | 
 11.2    EXPLAIN. 
   ,      . -
     . 
  , table,  ,      
.        ,   
       .    -
  orders, customers  books. (     
 .) 
 type ,      .  
,    ,   . 11.7.    
  ,      .   
,         ,  -
 . 
 11.7   ,    EXPLAIN 
 
const  system      .    
     .  system  
  ,     const. 
eq_ref            
  .  ,     
   ,    UNIQUE   
. 
ref           
    .    ,  
        , 
        
   UNIQUE    . 

 11.   MySQL I 
  
range          
    ,    
. 
index   . 
ALL     . 
         (books), 
     ref      -
 ALL, ..     . 
 rows      .     
   ,      
.   ,   ,   -
   .   ,     
    (.  9). ,     -
  ,     , ..   , MySQL 
    ,    . 
,     ,  .       
    ,      -
,      .     -
 . 
 ,   , , ,  , 
 MySQL     .     
   . 
 key      ,   MySQL,  NULL, 
     .  ,      
   orders  customers,        .  
 ,    . 
 ,    .    
  ,     .   -
,   ,    .   -
,      books),   . 
 ref  ,       
. 
 ,  extra      ,   
.       . 
 11.8     
  
 
Not     LEFT JOIN 
( ) 
Range checked for          
each record   ,   . 
(  
  ) 
Using       
( ,       
) 

  2.  MySQL 
 
Using index       , 
( ) ..    . 
Using      
(  
 ) 
WHERE used      WHERE. 
    ,     
 explain. 
-,   ,  ,    .  
     .    ,  
   .       -
       . 
-,      -
 ,       
.    : 
   ,      ,  
: 
>myisamchk MYI 
         ( 
  . 
>myisamchk 
! | ALL | PRIMARY | NULL 
1 PRIMARY 
PRIMARY 
HULL 
17 
4 
| | 
| NULL | 4 
| |  
| | 
| 
where j 
 11.3  EXPLAIN   myisamchk. 
 ,      .  
       (books),   -
.  ,         index. MySQL -
     order_items   4 ). 
,     ,     
.    ,        -
 .  ,   ,      -
  -     .    , -
  MySQL         
 FROM   . 
-,        .  -
   ,    .    -
       ,   ,    -
  .    ,     
. 

 11.   MySQL 
      
     ,   -
 EXPLAIN    NULL,    -
      .     
WHERE   ,       
,  ALTER TABLES, : 
ALTER TABLE  ADD INDEX 
   
    ,   -
,          
MySQL. 
  
,             -
 .      ,  
 .        -
    .    ,   -
       . 
   ,    (, 
TEXT, BLOB).       -
,        . 
  
     ,  EXPLAIN, -
    ,   .  -
,          -
.    ,    . 
  
      ,   
    .    
   .      : 
OPTIMIZE TABLE 
 : 
-r 
  . 
        -
,   , : 
>myisamchk 

 2.  MySQL 
 
    .    ;  
  ,     . ,   
  ,    EXPLAIN,    . 
    
  ,    ,   , 
    ,      . 
     INSERT. 
  
   Web- .     ,    -
 . 
: 
 
   ,        -
 . Web- MySQL      
.   : 
   
  ,   ,     
.       , : 
CREATE TABLE . . . 
  : 
          .  
  ISAM,    Indexed Access Method 
 ),    -
     . 
 HEAP.      ,    
    HEAP  ,     -
    .     
 HEAP       .  -
 CREATE TABLE      
""   .      BLOB, TEXT 
 AUTO INCREMENT. 
 BDB.     , ..   COMMIT 
 ROLLBACK.      MylSAM    
Berkely DB.           
 MySQL 3.23.21,         
  Web- MySQL. 
    ,      
. 

 11.   MySQL 
    
    MySQL,     ,  -
 LOAD DATA INFILE.         
.     . 
      ,   -
   : 
LOAD DATA INFILE INTO TABLE 
       newbooks.txt   books. 
           -
   ,       
 (\).       (\).  
      LOAD   
      MySQL. 
   LOAD DATA INFILE,   -
  FILE,    . 
  
    MySQL       
,    Web   MySQL  . 
      ,  -
   Web,    MySQL,  Web- 
MySQL  : 
  
     MySQL.   12    -
     Web-,    
. 

 
 
  
 
12 
13 
14 
15 
  
    
    MySQL 
  
   MySQL 

12


  
 
 


    , 


  , ,  
    .   
       
      
. 

,    : 

 ,      
  
   Web- 
    
   
  

       Web- 
    ,    
,      ,     
        
 . 

      ,  
  Web-; ,  
   . 

      
Internet.       
   .    
  ,     .   
Web-     
.      
     
     . 


 3.      

  Web- 

 Web- ,  ,      
 : 

        
   
      
      
   
   Web-      
.          
        . 

       ,  
 Web-:          
    . 

  

  90-  Web-      
 .          
  Web-,      Web  
   . 

           Web 
       
.   ,          
    . 

Web-      ,    
,   . 

        , 
, ,    .      
: 

    
   
      
    
     
   

     ?    ,  
  ,      ,    
   . 

          . 
 ,       
   ,    
,      . 


 12.     
  
" Internet   ,   "      
  ("")    Internet  , -
      Web-    -
. 
Web-       .  
     ,    , 
  ,    .  ,  -
          , -
     ,   .  -
      ; ,    
     . 
,          
,      ;   ,    
          
. 
     
 Web,     ,      , 
    .     ,   -
   ,          -
,   ,   Web-.  ,  
   ,     ,   
   . ,    -
 ,     . 
 ,   Web-,   
   ,     .   -
  ,   ,   
?  ,   sales@company.com,   
   ,     .       
   ,     -
 . 
   
    ,  ,   
,  .     , -
         . 
     ,    -
    . 
        -
     -    , .  
         -
 . 
,   Internet " "   .  
     (Peter Steiner),   
    5  1993 . 

236  3.      
    
 Web-    .     
   .  ,     , 
        ,     
  . 
  ,   , 
            
   ,     ,    
    .      -
 Web-    ,     -
 . 
      : 
  .  Web-     -
 .      ,  
     ,     -  -
 .      - , -
  .      , 
 : Analog (   http:// 
www.statslab.cam.ac.uk/~sretl/analog)  Webalizer (http://www.mrunix.net/webalizer). 
       
 Summary    
        . 
 .       
 .  ,       -
,         Web-. -
,         -
. 
  .     Web-  -
   ,        
    .   -
,       ,  
 - . 
  .       
      .  -
  ,         
. 
      ,  
       ,  
     ,   
  .     ,   -
,          
  . 
,    ,  -
         -
  .       -
 ,        .  

 12.    / 
       .    -
    ,      -
  .      ,   -
  . ,     ,   
  . 
      
     ,     
   ,   .   
 ,        .  
  ,    ,    . 
,        .  
       ,       -
        . ,  -
    ,       -
  -! 
   Web      .   , 
    ,    -
          , ,   , 
   . ,     
     ,  ,  , -
    ,  ,   , 
       . 
,   Internet  ,  ,   , 
   ,  , ,  
     . 
,   ,        -
      .   -
 ,       -
 . 
      ,   
;     ,      
   ,   ,      
 ,      . 
      . , 
, ,           
.     .    , CD-  -
 ,         . 
    . 
      :    -
   Internet.        -
    ,      - 
Use of Internet by Householders, ,  2000 (  8147.0), -
  . 

   3.     
   ,     -
 Internet   . 
 ,          
  , ,   ,    -
   .  , Internet   -
   ,     
. 
      .  
    , , .    
      ,    .  
 ,      ,   
.       ,  
 ..           
;  ,    . 
  ,     -
  : 
      
  
    
  
        . 
,    
          , , 
  ,    .      
.  , Web-    , ,  -
,   ,     ,   . , 
    ,    -
,   ,      . 
 Web       , ,  
 . ,    .  -
     ,  -
     .   Web-  -
  .  ,  ,  .   
    ,      , 
   ,     -
      . 
Web-  ,      . , -
,       -
.            -
  ,      . 
 
  Web-        -
,        ?   -
    . ,       
 ,       .    -

 12.     
   ,        , -
 ,     "". 
   ,      -
: 
      ?  
     ?      -
 ?    ?    ,  
    ,       -
.       . 
     ?    
  ,      , 
     ,     ,  
    "  ",   -
 Web- ,  ,  .  
        Web-. 
  ,  ?     
 ?        ? 
     ,   ,   -
,       .  -
  .        
        ,  -
  .      ,   
    . 
         ?  
      Web-,   -
          
,       .  , 
           SSL 
(Secure Sockets Layer    );     -
        -
.        . 
  
     ,    , 
          . -
 ,  Web-     .   
     ;   ,   -
  : 
Web-  ,  , .   ,   
       ,  -
  ,      . 
   .     .  
   ;      
  . 
     .   
   ,     

240  3.      
   ,    ,   -
    .      -
,        ,  
         
  Web-. 
    .   -
  ,        -
.   ,    -
     ,    
"" ,          -
 . 
 
Web-          
    .      
 -    ,      -
  ,    ,      -
 . 
     ,      
       .  ,  
     Microsoft Windows   Web- 
     Microsoft Internet Explorer  Netscape Navigator, 
 Apple Mac      Netscape Navigator,  Linux   -
  Netscape Navigator.       
 Lynx. 
         ,  -
    Web-. 
     
      Web,    , 
     .      
   ,  ,     , 
  . 
      .   -
      ,    ; 
        . 
          
       -
,    ,    ,  -
        CD-ROM.    
   Internet. 
US Patent and Trademark Office Patent Number Method and system for placing a 
purchase order via communications network (      
  5,960,411.         -
  .) 

 12.     
 ,       Internet, -
   Web-,     , 
    . 
  ,   Web-,    
     ,   . 
   ,        
Web   .  ,      -
         . ,  
    ,      
     . 
 ,    ,    -
 . ,   ,     
  ,   ;   Web   -
  ,      .  -
           
.         -
  . 
         -
,          . 
    
     Web,   
     . ,  - 
 UPS (www.ups.com)  Fedex (www.fedex.com)   , -
     ,   -
   .       
 ,     . 
        .  -
 ,       ,   
  ,    . -
     ,     
         
       .    ,  
         . 
  
      Internet   -
 ,       ,  -
   ,    . 
Web-        -
 . , ,  ,   
        Web-,    
  , ,     .  
   Web,      -
     ,     -
    ( )  ..    -
  :     . 
       -
.      Egghead.com.      

242  3.      
       . 
,        
,                
70   . ,     
 : ,  , ,   Internet. 
    .    -
 ,      ,    
   ,   ,  -
       .  -
             -
     . 
   
      , , -
  ,        
. ,    ,   -
   : 
  
    
   
  ,     
     
   
    
      
     
 
       -
   .     -
 ,       
     . 
   .      "" -
,      ,  ,   
      . 
     : 
    . 
  ,       
    .    
,   . 
         
  . 
         . 
           
. 

 12.     
 ,   -   ,  
        -
.          
  ;   ,     -
  . 
   
    ,     
      .   -
       .  
  ,     -
        . 
     Amazon.com (  ,  
   )        -
 2000 .    99   .    -
     boo.com,    -
    120   .     
     ,    ,  -
 
 ,        , 
    Web,     . -
   ,        
,   ,      -
      .      
          -
 . 
    
   
  Internet      -
 , ,       ,  -
  ,     .     -
     (  )  
   . 
        
.    ,     
     .       -
    . 
  
           -
    ,        .  
     .    -
  ,           -
  ,    . Internet   -
      .    
     . 

  3.      
,   ,    .   -
      . 
   
        .  -
          -
 ,       -
      .   
      . 
  ,      -
     ;   - -
     ;   -
       . 
     
          ( -
 ) .       
,      ,    -
 .        . 
         -
         -
.       . 
    
       -
 .     ,     
 . 
      , 
       ,   -
        -
      . ,  -
       . 
     ,    
        . 
  
 ,    Internet    
.     :   
    Internet.      
         . 
,       Web-    -
   .       
 .       ,    
    .   ,    Web, 
           . 
  
        : 
,    . 

 
  
 
 


      


 .  ,     
 ,    , 
  ,    
  ,     
   Web-,    
,   . 

     : 

    ? 
   
    
    ,  
  
   
   
   
     
     
   
   
  Web- 
    
  
    
   

 3.      

246 

   ? 

    ,       
,    .       
        . 

  ,       
    ,     .     , 
       ,   
 ,    . 

,      -,  
    .     ,  
         .  
     ? 

, -    ,  
       . ,   
 ,  ,  ,    
     ,        
   .       
    .     
    ,      
        . 

        ,  
  .       
,       
  ,   ,       
 . 

      ,     
      ,  
. 

  

     ?    ?
          


12.        . 
    Web-,      
: 

    
     
   
    
    
    
     . 


 13.      
  
,           
,   .    , -
     , ,   . 
    ,  , -
, ,      . 
,      Web- ,   -
     . Web-     
  .        
       ,   Web-  
  . Web-     -
     ,    , 
 ,     . 
         -
      ,     
.   ,  ,    -
     ,  , 
 ,     Web-   -
 . 
  , ,   ,  
    , ,    ,   
,         . 
         
  Web-.  ,   ,   -
 .    ,  ,  -
       . ,   -
,     .       
         ,  
   ,   ,    
 Linux  Windows NT,      , -
       . 
 (authentication)      
.   ,   ,   ,   -
  .     ,   
        (digital 
signatures).      . 
 CD Universe       
     ,     -
.  ,   1999 .. ,   Maxus, -
   CD Universe, ,    300000  
,      .      -
 100000    ,     . -
         ,   
   ,   Maxus   -
      . 
       , ,    -
      scp (secure copy   ). 

248  3.     
 13.1 
 
  
Internet   
 
  
  
 
 . 
  
Internet 
          . 
    TCP/IP    ,  -
   -      Internet,  
      .  TCP/IP , -
             - 
      .  ,   
      ,    . 13.1. 
          -
  . 
  ,          
,   traceroute  UNIX-   
Windows-.     ,   -
       .      -
        .   , 
   ,    20  .  
    ,       -
,      . 
         
  . Web-    Socket Secure 
Layer (SSL),   Netscape,     
  ,   Web-  .  
          -
,             
  ,      
 ,    . 
   
     ,    .   
           , 
  ,   ,      ? 
       ,      -
   . 
,  -        -
 .  ,      -
  -,   ,      . 

 13.      
        ,    -
 - .   ,    -
   ,        
. 
   ,    . -
    .    , -
    .      
.  ,   .   
RAID   .       ,   
 . 
  ,        -
    .       -
. ,  ,  ,  , -
   . ,      
 ,     ,   
    .  ,  -
      .   ,   
     -  ,  -
         . 
  
      ,  ,     
     .  ,  -  
      ?       
     ,      -
 ? 
         
.          -
 ""   " "   - -
.         -
,    ,   " "   
. 
,    ,     -
 (signature).       ,   
 ,       ,  -
 ,    .      
 ,          
 . 
    ,   ,   -
       . -
        -
.    ,    
 ,         -
     .    
     ,  Windows 98  Windows 95    
    . 
     .   - -
  ,    ,   , 

  3.      
     ?  ,   , -
  ,    .    -
     .   , -
     .    ,   
    ,      
,    ,      "". 
      Tripwire 
    ,      
,     .    -
      .   --
        http://www.tripwire.com 
   
              
 (Denial of Service, DoS)   ,  -  
          -
 .  ,       -
     . 
  2000 .         
 (Distributed Denial of Service,     Web-. 
      eBay, Amazon,  
Buycom.        ,  -
      .  -      DoS 
      .      
  ,     ,  . 
  ,        , -
     DoS.      -
  ,       
,    (reverse spamming)     
 .     (reverse 
spamming)   ,  -     
(spam),        .  , 
     ,     . 
  ,    
 DoS   .       
       , -
   -      .   
   ,     -
      .      
 ,       ""   
  . 
 ,    DoS  . ,  -
 ,     ,    -
    DDoS.     -
,       ,  
 , , ICMP.     , 
      ,     -
 .        -
     ,      DDoS. 

 13.      1 
   ,       , -
          -
      ,       
 . 
   
 ,    ,   , 
   ,  . ,   -
 Web-    ,    ,  
    .     
      . 
       ,  
 ,   ,      -
 . 
      ,   
.     ,  -
,  ,   . 
  
         , 
 ,        .   
     ,    -
  ,      , ,   , 
     .     
    ,     , 
    . 
  
      .  
 ,        ,   -
 . -    .  -
 ,     ,    
        . -
       ,   -
          ,  -
  ,       ,  
  . 
    ,    . -
    ,    -
    ,       -
   - ,    ,    
   .       -
,        
. 
 ,      , 
 ,       -
 . 

  3.      
  
         -
          -
 .      ,   Web. 
       ,   
        
 .         
, ,  ,        
.       ,  -
         . 
     ,      -
,      .    
   ,          
  .        -
,   .        -
,  .  ,  ,    
.   ,      -
   . 
   
 ,    -     
(repudiation).       .    -
    ,     Web--
,         .  
   ,    -   
,     ,     . 
         
     .      -
     , ,  ,    
         
 ,   .     . 
     ,    . 
    ,    -
 (digital certificate of authentication)    . 
         -
.   , ,   Corp Pty Ltd   -
.   ,   *     ,  
 .   ,     -
     . 
    ,   -
,        -
         -
 .      , 
,        -
 ,   . 
     ,  
        -
,   VeriSign (http://www.verisign.com)  Thawte 

 13.      
www.thawte.com),      .  
     ,    -
  ?      , 
 ,           
,       . 
  1997 ., ,  VISA     -
,       (Secure 
Electronic Transaction, SET).     SET     
       , -
  .     ,    
           -
  Internet-. 
 ,      SET    
,          SET-co- 
   .    -
     ,   -
 .  ,      
       .  
          "-
 " (digital wallet),   -  , -  
       ,   - 
         . 
   
   
   Web  ,  . Web   ,  
        -
 .        -
 Web-,       Internet,    
     . 
   ,     
 ,     .     --
 ,     , -
       .      -
    ,     . 
 , ,      
 .     ,     
, ,       
 ,    .   -
     .   -
, ,  ,   , -
 ,   ,    
  .    -
 ,   ,       Web-
.      , -
         ,  
   . 

 3.     

254 

,       
 .       
 ,   .     
   ,    ,   
           
  . 

   

    ,  : 

       
      , ,  
     
    ,     
 
          
    .    
    ;     
          .  
     . 

      ,    
      .    
     .    
      ,    
  ,     . 

  

    ,  -     
,    .     , 
,       ,    ,   
 . 

   ,  ,  
,    ,       
, ,   (-).  Web  
        . 

   ,    , 
        
  ,     . 
           
 ,         ,  
 Web. 

  ,  ,       
.     ,  
           
 . 

   .       . 
  ,         ,   



 13.      
  ,     .           -
  ,   .      -
         
. 
   .      -
,  50%   ,    . 
,    , ,      
  .        -
       .     , 
       . ,  
      ,    
  25%      .   -
   ,     -
   .        
       ,    
    .     ,  
      ,      
   . 
       
 , ,  ": : rover",  
      . 
           , 
,    ,      -
,    . 
    .    
        (sniffers), 
      -. -
        . 
,    ,     -
   .    , 
, ,      ,  
      ,  . 
 
      Web-  -
. Web-        ,   
      . 
         ,   
 ,    . 13.2. 
 13.2. 
Web-   
  
  
   

256  3.      
Web- Apache  Microsoft IIS     -
     .      MySQL  -
     . MySQL    , 
  .        
       . 
       14. 
  
      -
   ,    . 
,    ,    (plain) ,  
     ,     -
     .    -
 , ,  ,    .  . 13.3   
 -   .      
  ,        -
  Enigma    .     
   .     . 
 13.3.            
 ,    . 
   ,      . 13.2  
  ,      -
,   Apache. (     
   .)       -
.           
     ,    -
      . 
     .   -
     .    
      .   
        . 
,        .  -
  .  . 13.4    -
. 
   4000 ,      
     .       
        -
   ,  70-     -
   ,   90-     
 .         
,            -
,  ,           -
  ,    -  Web. 

 13.      
 
 
 
 
-
 
 
 
 
 
 
 13.4.            
 ,    .     
         . 
     . , -
, DES,  ,   . , , RSA, 
     . 
    
    (private key encryption)   ,  
      .     
 .       ,      -
    .    . 13.4, 
 (  )   (  -
)      . 
       DES (Data Encryption 
Standard).  ,   IBM  70- ,   
       -
.         
 70- ,   DES      1998 . 
        RC2, RC4, RC5,  
DES (triple DES)  IDEA.     
    ,   DES,    ,  
     .      -
 ,     ,     -
  . 
        ,   -
 -       
    .        -
 ,          ? 
,  ,   1976 .,     (Hellman) 
     . 
,  DES        DES.  
  ,        DES,  -
 ,     DES  . 
9 216 

   3.      
    
    (public key encryption)    -
     .    . 13.5,   -
   ,      . 
 
 
 
 
> t 
 
 
-
 
 
 
f 
 
 
 
 
 13.5.          
. 
     , ,    ,  
   .  ,     
,     .    
  ,      . 
         RSA,  
   (Rivest),  (Shamir)  (Adelman)  
      1978 .  -
 RSA   ,       -
 2000 . 
        
     ,  ,    
  .   ,     -
   .     .   -
         ,  
       .    
,           -
   . 
  
  (digital signature)      , 
       .   -
      .   , 
   ,    .  
     ,     , 
   ,    ,    , 
    . 
     .   -
,     ,      -
  ,    . 

 13.      
 ,    ,     -
  .          , 
       ,   -
    . 
         -
 ,       
,  
-   ,  -,   
 .   ,    . 
,      , ..   
     ,      .  , 
,         . 
  -   MD5  
-  ,   . 
    ,  ,    -
,     ,        . 
, ,          -
  -    ,    
         -
.         , -
  . 
      .  
     .    
-     -,   .  
 -    ,  ,  
        . 
  
    ,     ,  
      -
    .      
         - -
   ,      . 
         
      .  ,  -
           
.  ,         
 ,      . 
   ,        
,  ,   .     
  ,     ,  .  -
      ,   -
    ,    . 
      (Certifying Authority, CA). 
       , -
       .    -
    Verisign  
Thawte  Thawte   -

260  3.      
 ,       . -
      ,   Equifax 
Secure   . 
   ,  ,   -
     .  ,  -
       . 
   ,      -,  -
 .   ,    ,     
     ,     . 
    . ,    -
 ,        ,  
   .      -
 ,     ,    , -
     . 
 . 13.6   ,   Internet Explorer  
 .  ,  www.equifaxsecure.com  , -
   Equifax Secure E-Business.  ,   , 
 ,    Thawte Server. 
         
     .  , 
    , Web-   
SSL-           
 . Web-,   SSL-,  -
  Web-. 
Web- 
    Web-   Secure Socket Layer -
   Apache, Microsoft IIS      -
 Web-.   Apache     
  Unix,   ,  ,   
,      ,  IIS. ,  Apache -
    Windows NT. 
 13.6. 
  
com 
   
 , 
  
 . 
Secure 
OK. 

 13.      
  SSL   IIS,   IIS,  
     .    SSL   
Apache     : Apache, Mod_SSL  OpenSSL. 
    ,   Stronghold.  Stronghold   
    1000  .   -
   Apache      
,     SSL.  ,   - 
Unix          -
. 
          
Web-  Apache  IIS.      SSL,  
 ,      ,  
    .    SSL 
       . 
        -
,        ,     -
    ,      
 . 
       (Certificate Signing Request, 
CSR).       .   
  Web-  .  Stronghold  IIS  
     ,   Apache    . 
  ,        .   
        . CSR 
   : 
----- BEGIN NEW CERTIFICATE REQUEST -----
----- END NEW CERTIFICATE -----
  CSR,  , , -
,   ,   ,     -
      ,     -
   . 
    ,      -
   Web-,   .     
 ,       CSR. 

262  3.      
   
       . 
       :  , 
   ,       NT, a 
   ,   su (    Unix-
,    ,  , root). 
  ()    -
     .      
,   ,       -
  .       -
  . 
        
,     ,    -
.        -
  ,   ,   -
  ""    .    
        . 
     .    -
    ,     , 
    . Unix     -
   .  ,    ,  -
 ,   ,   .      
Windows NT,    . 
      ,   
    ,     -
. 
 
 (firewall)     ,     
  .    ,   
,        . 
         . -
     ,     -
 .      , -
   . 
        
.    ,  ,  
        -  
   . 
     ,    
  ,  ,   .   
,         .  -
   ,       .   -
  ,     ,     
  . 

 13.      
    ,  ,  ,  
   .      ,   
         . 
   
         -
 .       , -
   - ,      , 
       . 
      Web-   
,    .       , 
  .    ,    
   .  ,     
, ,   , ,    -
. 
         
  RAID (Redundant Array of Inexpensive Disks   -
  ),    .   
     .   ,   -
,  -     RAID-,   -
 . 
      ,   
  .       -
  , ,        -
,    . 
       .  
   ,     ,  
   MySQL. 
   
    ,   
     HTML, PHP,   ,  -
   . 
        -
 AMANDA (Advanced Automated Network Disk   
   .       
Unix        Windows- 
  SAMBA.     AMABDA  -
   http://www.amanda.org 
     MySQL 
      . -
   - ,       
. 
       MySQL 
   

264  3.      
  
        -
 ,    ,       -
  .       
 ,  (  ,   ),  -
   . 
    .     ,  
  ,   . ,     
  ,     .    -
    -      -
    . 
       ,    
.           
      -
  ,    ,   -
 ,         . 
         http://epa.gov/ozone/ 
       .    -
        -
.       ,    
    (, UPS, Uninterruptible Power Supply). 
        10 ,  
 300  .        
  .      -
 ,     ,   . 
    ,     -
,      Internet,     .   
 ,         
,    Internet    -
,             ,  
   . 
      ,    -
       .  -
         -
  ,    ,   
,     Internet   ,   
     ,   -
  . 
  
  14        -
    .    -
  ,   ,     MySQL. 

14 

 
  
  MySQL 


   ,    
   MySQL   
. 
     : 

   
    
   
      
      
 .htaccess  Apache 
     IIS 
     
mod_auth_mysql 
     
  

Web     ,    
,    .     
,      
   . 

  ,    
      ,  
  .  Web-  
,   ,   
  .   
      , 
    . 

   Internet   
 IP-.      IP- 
.  ,    ,  
       
  .   


266  3.      
  ,   .  ,    -
  Internet   IP-.  ,  -
        -
   IP- .        , 
     ,      
,  , ,   IP-. 
    Web, ,   ,  -
  .        
,     . 
 Web-      . 
,     New York Times -
   ,      , 
  ,     .      -
 Slashdot (http://www.slashdot.org)   -
          , 
  (nickname).     -
        .  
,           
. 
       ,  - -
         .  -
,    ,    -
   ,      ,   
     ,    -
   cookie-   .  -
    .     
     ,   -   
.   ,     -
  ,  .    ,    -
 -  ,   ,    . 
    13,       -
 .     Web   -
        . -
          
  . -
     
   , -
,  
  
 
   -
 . ,   -
 14.1,     -
 .    
  ,  -
 HTML-   
     (. 
. 14.1). 
Please Log In 
This is 
j 
 14.1.  HTML-  
      

 14.     MySQL 
Go Away! 
are to view this resource. 
S ' | 
php 
' 
Search 
Here it is! 
I bet you are gtad you can this secret page. 
 14.3.     
,    
. 
 14.2.    
 ,    
  .     
    . 
    ,   , -
    (. . 14.2). 
       ,  -
  .       . 14.3. 
   ,   . 14.1, 14.2  
14.3,    14.1 
 14.1 secret.php  -  HTML-     
 
//      
<hl>Flease Log In</hl> 
This page is secret. 
method = post action = 
border = 1> 
<tr> 
<th> </th> 
<td> <input type text name = </td> 
</tr> 
<tr> 
Password </th> 
<td> type = password name = 
</tr> 
<tr> 
<td =2 align = center> 
<input type = submit value = "Log 
</tr> 
</table> 
else 
{ 
//      
echo it 
echo "I bet you are glad you can see this secret 

268  3.      
else 
{ 
//      
echo 
echo "You are not authorized to view this 
,    14.1,   ,  
    ,   -
   . 
 : 
          
       
     
       
         . 
 
      ,   , 
.     .   , -
   ,    .     -
   ,        
 .          
       ,    -
 . 
          
,   ,     -
 .         
       , ,   -
,        -
 .         :   
        100 ,   
  . 
           
 ,       -
.          -
,        . 
        -
    14.2. 
 14.2.    MySQL    
  . _ 
<? 
{ 
//       
?> 
<hl>Please Log 
This page is secret. 

 14.      MySQL 
method = post action = 
<table border = 1> 
<tr> 
<th> </th> 
<td> type = text name = </td> 
<tr> 
<th> Password </th> 
<td> <input type = password name = password> </td> 
</tr> 
<tr> 
<td colspan =2 align = center> 
type = submit value = "Log 
</tr> 
{ 
//  MySQL 
= 
{ 
echo connect to 
exit; 
} 
//     
$mysql = 
( 
echo select 
exit; 
} 
//    ,  , 
//    
= "select from auth where 
name = and 
pass = ' 
$result = ) 
if (!$result) 
{ 
echo run 
} 
$count = $result, 0, 0 
if ( $count > 0 ) 
{ 
//       
echo it 
echo "I bet you are glad you can see this secret 
} 
else 
{ 
//       
echo 
echo are not authorized to view this 

270  3.      
      ,   MySQL 
  root      14.3 . 
 14.3. createauthdb.php       auth, 
   . 
create database auth; 
use auth; 
create table auth ( 
name not null, 
pass not null, 
primary key (name) 
insert into auth values 
( 
insert into auth values 
( 
grant select, insert, update, delete 
on 
to 
identified by 
 
  ,            -
         . -
        
 . 
PHP-     
  : 
string crypt (string string 
        . 
,      "pass"     
         -
   "pass"   ,       
     .    ,   , 
    .         
  salt         . 
   
== "user" == "pass" ) 
{ 
//   
} 
    
= && == ) 
{ 
//  

 14.      MySQL 
   ,     -
    ,     
  ,     
  ,       -
   .         -
. 
        MySQL, 
  PHP-  MySQL- 
    ,     .  -
           -
    . 
   PASSWORDO   14.2  SQL  
 : 
select from where 
name = ' and 
pass = 
       auth,     
name     Sname    pass   
  PASSWORDO,     
,       ,  
   0  1. 
 
          . 
  HTTP-   ,    -
            
.        -
,    . 
         -
    Web-.    . 
    ,   -
    ,   .   
      
   (prepend)    (append)     -
.       5. 
   ,   ,   -
    ?      -
 ,    . 
         
.         , -
  URL,        
 . 
      .   -
      Web-,  
,   ,     , 
    .       -
            -
  .         -
   ,   ,   . 

272  3.      
         HTTP--
  .      
,       Web-   -
.      .   -
 HTTP-,       20  24. 
  
 ,       
    ,   HTTP-. 
  Web-     Web-. -
  Web-        - -
      . 
 Web-        
, Web-       -
 .       ,   
 ,         -
. 
  HTTP-   . -
         Web-. 
  ,   PHP, Apache  IIS. 
          -
     .  HTTP 1.1    -
,  - (digest   -
   ( , MD5)    
. -    Web-,   
    . - -
   Microsoft Internet Explorer    5.0.  -
   Netscape Navigator  6.0. 
         , -
       .  ,  --
    .        
 ,       ,   -
   .        -
 .        -
 ,  ,   ,   
  . 
   ()  ,  , 
      Telnet  FTP.   
      . -  
      .   SSL  
         Web. 
      15.     
       ,   
 . 
         
     .  ,   
      .    -
       ,    -

 14.    MySQL 
     .   -
          -
         . 
     
PHP-,  ,   -,  -
      ,  
.  HTTP-       
      ,     -
 Apache   Apache     IIS.   
 14.4      . 
 14.4   HTTP-  
  . 
//    IIS,   
//  $PHP_AUTH_USER  
if 0, 9) == "Microsoft" SS 
&& 
&& 
AUTHORIZATION, 0, 6) == "Basic 
) 
{ 
= 
} 
//    if     -  
if "user" I | != "pass") 
{ 
//        
//     
Basic 
if 0, 9) == "Microsoft") 
401 
0 401 
echo 
echo "You are not authorized to view this 
} 
else 
{ 
//   
echo it 
echo bet you are glad you can see this secret 
   14.4   ,         
.      ,     
.     ,   
     .    , -
   

274  3.      
 14.4. 
  
HTTP- 
   
  
  
 . 
'  I 
1 I I 
Back . . 
       .  
  HTML-     .    
   .     , 
        -
.  . 14.4    ,     
Internet Explorer. 
      , 
        
. Internet Explorer     ,  
    ,      . Netscape 
Navigator    ,    -
       "Authentication Failed. Netscape -
     ,      -
 Cancel. 
      14.2,       -
  ,   .      -
     . 
      
.htaccess  Apache 
,    ,      
 PHP-.  Apache     
,       -
  .         
  mod_auth,    -  -
    . 
       , -
   HTML-         -
    .       HTML--
,      HTML-    

 14.     MySQL 
  14.5   HTML-,    , 
 .   content.html.  14.6  
HTML-       .    
rejection.html.  ,      , -
  ,        -
      . ,    -
         , 
     ,     
            -
 ,    . 
 14.5. content.html   . 
<hl>Here it 
<p>I you are glad you can this secret page. 
 14.6. rejection.html     401. 
<p>You are not authorized to view this 
     .       
  14.7.     .htaccess.      
  ,    . 
 14.7        
  Apache,   . 
401 
AuthGroupFile 
AuthName "Realm-Name" 
Basic 
require valid-user 
  14.7       . 
       ,    -
      . 
  
ErrorDocument 401 
  Apache,     ,  -
 .  ErrorDocument      
 ,          
 HTTP, ,   404.    : 
ErrorDocument 
,       401     -
.          -

276,  3.      
 ,      ,   -
     . 
 
AuthUserFile 
    ,   .   
       .     
 ,    .       -
  Web- ..    ,      
 Web-.        14.8. 
       -
,  ,       -
   .        
 
  AuthGroupFile      
 UNIX-,    . 
     ,   HTTP-  
   .     
"Realm-Name" 
    ,   ,     
 .    ,       -
 ,    "Realm-Name" ("-"). 
     ,  -
,     . 
Basic 
  ,   .    -
,  , ,    ,  -
 . 
 
require valid-user 
,     ,   -
. 
 14.8.          
 . 
         -
,  . 
     .    , 
       -
 Apache. 

 14.     MySQL I 
        . 
username 
 
htpasswd passwordfile username password 
     -.    htpasswd, 
    .       
.          
,     ,  htpasswd     
     . 
  m, d, ,  s      
 (   ). 
 b       ,   -
  .      htpasswd   -
    ,        -
 htpasswd   . 
      ,   
 14.8. 
htpasswd 
htpasswd -b user2 pass2 
htpasswd -b user4 pass3 
htpasswd -b user4 pass4 
    ,      . 
       .  ,  -
  ,   .htaccess,    
            
    .     
          Web--
.      htaccess    ,  httpd.conf 
     .     
,         . 
     ,     
 .  ,     ,  
 ,         -
 . 
   IIS 
   Apache,  IIS   HTTP-.  
 ,  UNIX-    
    .    , -
  IIS    . 
 Windows 2000   Internet Information Server 5 (IIS5) -
    Internet Services Manager,     
Administrative Tools ( )   . 
 Internet Services Manager    ,   
. 14.5.       ,     
 windows-server   .    Default Web 
Site  Web-,   .      
protected,    content.html. 

278  3.      
 14.5. 
 Microsoft 
Management Console 
  
 Internet Information 
Server 5. 
      protected,  - 
        Properties ()  -
 . 
  Properties       -
.    Directory Security ( )  Custom Errors 
( ).     Anonymous Access ( 
) and Authentication Control ( )   Directory 
Security.    Edit     , -
  . 14.6. 
           
.       . 14.6,    
      ,  -
    . 
    ,    , 
      .   
 Custom Errors      Authentication Methods. 
 Custom Errors,   . 14.7,    
   .         -
    ,   .    
    14.6.  IIS   ,   
Apache,     ,  IIS      
     .   401,   
,  IIS    .   -
    ,       -
     ,      -
 . 
 14.6. 
   
  
,   
  
. 
. 
fa 
i fiiethu*, and p 
 . 
' 
i 

 14.     MySQL 279 
 14.7. 
 Custom Errors 
  
   
   
. 
Apply 
 ,         -
    IIS5.     Windows,  IIS5  
,     UNIX,       
     .  ,  IIS5   -
 ,      . 
      ,   -
,         
 .        
"password",            
         .   -
     Web    . -
,         ,  -
   Web-,          
 ,  Telnet. 
    
mod_auth_mysql 
   ,       
mod_auth   Apache.         -
    ,   -
    . 
 ,    mod_auth_mysql    
   mod_auth      .  -
   mod_auth,     ,  
      . 
   ,     ,  
    . 
 
       Apache 
 MySQL,     .    

280  3.      
   .   README  USAGE   
 ,      . 
1.    .      
CD-ROM.        
 
2.   zip  tar    . 
3.       configure.  -
     MySQL     Apache. 
  ,    : 
    . 
4.  make,   make install.    configure   
Apache     
        
: 
\ 
\ 
\ 
5.         
   ,      .  
      ,   -
 ,     auth    -
   . 
6.         
        ,   
    : 
hostname user password 
? 
  ,       -
,    Apache.    Apache  -
 : 
        
httpd.conf, ,  mod_auth_mysql  . 

 14.     MySQL 
  
       -
,     14.9    .htaccess,  
     ,   
       . 
 14.9.        
   MySQL 
401 
AuthName "Realm Name" 
Basic 
auth 
auth 
name 
pass 
require 
 ,        ,  
  14.7.         401 ( 
).        . 
    14.7,    ,   -
 .        
   ,   14.9   
  .  Auth_MySQL_DB, 
   -
, ,   ,       -
. 
     -
   .      MySQL.  
     Plaintext,  MySQL. 
     UNIX  
 DES. 
   ,       
,     mod_auth.       -
.    ,     
,       . 
  Web-     
  .       
        .    
    Web-     -
     MySQL. 
    
      ,  
   ,     ,  
     .     -
         
 ,      . 

282  3.      
  20     ,  
      , -
  ,    . 
  24         -
.    ,     . 
  
 HTTP-    RFC 2617,   
  
       
 Apache,    
       
 
  
           
  ,   .     SSL, -
   . 

 
 
 
 PHP  MySQL 
  ,    -
    ,  
     -
   ,    . 
     : 
    
     
     
     ? 
     
   
    Internet -
        -
       .  
     . 
 ,     -
  .    -
 ,   ,    
   ,   -
  . 
      -
       -
.      -
,      
  . 15.1. 

284  3.      
-
 
 
  
 
 
 
MySQL 
 15.1          
 
  ,   ,   -
       ,     
 ,   .     
.    Web-     
,      Internet   Web-. 
   PHP-,  Web-    
   . 
PHP-       .    -
 -  HTML-     
SQL-  MySQL,    .    
      . 
      : 
   
 Internet 
   
       , . , 
   Internet     . 
  
    Web-    ,    
    ,     . 
  ,      
        ,   
   ,   . 
         ,  
       ,     
HTML-,      

 15.       MySQL  5 
  ,     , -
     , , Java, cookie-  
JavaScript.     ,   ,    
    ,    , -
        . 
        Web-, -
  40- .      2000 . -
 ,     ( , 
  )  128-     
,          .  
          , 
,  Web-,      . SSL -
        -
   . 
 ,     ,   Web-  
 ,     .    -
   , ""   ,    -, 
     cURL    
. 
  cURL,    ,  -
   17.   ,    ,    
    . 
        -
,     .      
  ,        
(),     (JavaScript) . 
,  ,      -
,      HTML-.  -
  ,     JavaScript,   -
     . 
   ,       -
,            -
   JavaScript      , -
,  . 
       (    ) 
    (cookie-).  cookie-  
   ( )    20. 
     Web-    .  
 ,         
 ,   . ,    
,     ,    ,   
  ,           . 
Internet 
     ,  Internet   -
 ,       . 
Internet    ,     
  .         

286  3.      
 ,         .  
    13.   ,  ,   -
. 
,   : 
     ,  ,      -
 . 
    ,     
  . 
 ,        , 
     . 
Internet       .   , 
    ,    .       
  ,    ,   
     , , , .   -
     ,      13. 
 ,           
   Internet. 
,  ,     ,     
Web-  Internet: 
 SSL (Secure Sockets Layer,   ) 
 (Secure Hypertext Transfer Protocol,    -
) 
   ,     -
  ,   SSL  ,  -
  . SSL     . 
  ,     ,   
.     . 15.1  .    
     ,      . 
      ,  -
  Web    .   -
    .     -
  ,         
,    .     
    . 
       ,  -
  ,      -
.         -
        , 
     .     -
      ,    
  . 
 ,       ( ) -
     SAPI Web-,      CGI. 

 15.      MySQL I 
,       ,       
. 
         
   Internet?       -
?   ,     
   ,    SSL. 
     SSL   
  .    ,     
     .  , , , -
   MySQL          Web-.  
   MySQL  TCP/IP,     .   
    ,  ,    . 
    Internet,  , ,   
,       ,      
  Internet. 
         SSL. -
  HTTP,    SSL   -
 cURL.      17. 
 ,    ,      ,  
    .      
      ( -   
    ),   SSL,    -
 ,      
 . 
   ,  ? 
    ? 
           -
. 
    
   (SSL)    ,  
  Netscape      Web-
  Web-.          
      . 
   SSL   2,    3.  
Web-    SSL,     
  . Internet Explorer  Netscape Navigator  SSL,   
 3. 
    ,  ,  
   .         
   .      . 15.2. 
     HTTP,    
Transmission Control Protocol (TCP,   ), ,   
,   Internet Protocol (IP,  ).   
 ,       
    ,    . 

288  3.      
FTP ... 
TCP/UDP 
IP 
 
  
  
  
 - 
 15.2  ,    , HTTP. 
HTTP    .    -
 SMTP  telnet (   . 15.2),   POP,    
. TCP        ,  -
 TCP/IP. IP    .      -
  ()  .       TCP/IP  
,          -
 . 
          
 .           -
. 
 SSL        .  
SSL       .  
   . 15.3.  SSL  ,    
HTTP,     . 
  
HTTP   
SSL SSL 
 
 
 
 SSL 
  SSL 
TCP 
IP 
- 
  
 
  
  
 - 
 15.3 SSL      ,     
     . 
 SSL        -
  HTTP,       HTTP.  -
     ,   SSL   
, ..        ,  
  .  ,     -
,   . 
 Web-    Web-  HTTP,  
      (-
),      . 
       : 
1.    ,  SSL,     
. 
2.     . 

 15.     MySQL 
3.    ( )    -
. 
4.         -
.        . 
5.      : 
          -
     . 
5.2.         ( 
           -
       ). 
5.3.           
 -. 
   ,   -
,         -
 ,       .  -
,  ,         
 ,        . 
   SSL-   : 
1.    . 
2.   () . 
3.       (message authentication code, 
MAC),    
MAC      . 
5.         
. 
    . 15.4. 
 
  
  
   
  
TCP- 
 15.4 SSL    ,  ,     . 
. 216 

290  3.      
     TCP    
.  ,      .   -
      ,   . 
,     SSL   ,   , 
         ,  -
  . 
       -
.     ,       
    ,     -
.   ,  SSL,    -
 ,    . 
 SSL  ,       
 ,        
. 
    SSL 3.0 ,  ,   TLS 
1.0 (Transport Layer Security,   ),     
 TLS    ,       
  . TLS     , 
  ,         -
.    SSL 3.0,    . 
   
       ,  
    .          
       , , -
  ,   . 
         -
 .     . 
         -
   .    ,   -
      .     -
 ,    
  .   magic_quotes_gpc  
   php.ini.     
     ,  
      GET, POST  cookie-, 
a   ,      . 
        -
,   ().      
   ,     -
       . 
     HTML- PHP-   
       , -
     . 
      -
   HTML-. ,  <   -
         -
. 

 15.     MySQL 1 
    
     (HTML-  PHP-,  
   MySQL)          -
,   . 15.1   .     -
,      . 
    .  Web-  -
  .        
  Web-.      , 
    Apache    IIS.  -
     ,        
 . 
       Web-.    
     .  ,   ,   
   Web-,         
    ,      Web-.  
  ,       
   Web-. 
     ,      
   Web-.        
.        . 
     .     
  . 
,   Web-     
   ,     ?    -
 ,         
.     ,  ,     
  ,     . 
   Web-      ,  -
         .   
           -
    , ,   . 
     ,     -
.  MySQL  ,       -
   .   ,       
   MySQL.     ,   -
    MySQL,     
    . 
    :   PHP-  
     MySQL. PHP-    
.      ,    
.   Web-  ,      
  . 
 Web-       .php  
  ,       
 .   ,      -
.   .inc   Web-,      
  .         Web-
     ,        
,       

 .      
 Web-      ,    MySQL  
   .    ,   -
,     .     
 Web-  ,     
,    Web-   .    
  Web- ( ,  ,      
),          
 . 
    ? 
         ,  
  .  Internet    -
    . ,        
,    .  ,   -
,    . 
     ?    
      ,     
      ,     . 
    , , -
        ,    .  
        Web-. 
          ,  
   , ,  -
   ,        -
        . 
    
,   ,   , -
    .  -    PGP 
- Pretty Good Privacy (  ).  .  
(Philip  PGP   ,    -
 . 
   PGP,      -
  .       
 . 
           -
    ,       
  PGP         -
    Network Associates.     
  PGP         -
  PGP: 

 15.      MySQL 
   PGP    . GPG  Gnu 
Privacy Guard (  GNU)     
  PGP.         
     - . 
       .   -
    ,  PGP     -
, ,     ,  -
    . 
GPG     
    , , ,  -
   GPG    ,  PGP   
(   ).      GPG  -
    Web-.     PGP 
    . 
     GPG. , GPG  
  .    ,   :   
,      . 
 GPG 
  GPG  Linux ,    -
    www.gnupg.org,     gunzip  tar. 
        ,    
  Linux: 
configure (    
make 
make install 
     root,   -
    
    ,    root     
    GPG. 
   ,  GPG      
   .      -
     GPG. 
 Windows-     zip-, 
     gpg.exe  ,    
PATH. (  C:\Windows\  - .)    
        gpg. 
 ,   GPG  PGP      -
,     . 
 Web-        GPG 
 PGP,      GPG,   -
 .   ,     ,   -
   PGP,     
 ,     . 

294  3.      
        ,   . -
,        (Public Key),   
 ( PHP-)       , 
   (Private Key),       -
     . 
,         ,   
 Web-,         . 
        GPG,  
  : 
gpg 
   ,        
,   .      ,  
    .    Welling 
   . 
         -
: 
gpg > filename 
     ,    GPG-  
PGP-   .      ,   
  ASCII- : 
gpg -a > filename 
        Web-  -
 FTP. 
 ,     UNIX.  Windows   
 ,        . 
       Web-  -
    ,      : 
644 
   ,  ,    -
 PHP-,   GPG.    , 
  ,   .       -
 . 
     Web-.  -
         Web-  
 nobody.      . (  
 ,     .)   
su root 
nobody 
    nobody        -
   GPG.      
 nobody. 
        Linux-
  nobody  /,  nobody      
.   BSD-  nobody    -

 15.      MySQL 
   ,     .    -
 nobody     ,   Web-
    ,     . 
 
cd ~ 
 nobody     .    
  : 
gpg 
  nobody    ,    
     .      ,  
       . 
      : 
gpg filename 
  GPG,     ,   
  
gpg --edit-key Welling 
      . ,    -
   Welling   , -
   ,    . 
          
  trust (), sign ()  save (). 
 trust  GPG,     , sign -
         -
 nobody, save         . 
GPG 
     GPG     . 
      test.txt,   
. 
  
 - Welling test.txt 
(    )    
gpg: Warning: using insecure memory! 
     test.txt.asc.    ,  
  : 
----- BEGIN PGP MESSAGE -----
Version: GnuPG 
Comment: For info see 

296  3.      
PGP 
     ,    ,   : 
gpg 
    . 
    ,     ,   
 -: 
gpg -do test.txt.asc 
 GPG  ,  ,     -
,      ,    . 
 -  ,      
    GPG. 
  15.1  15.2 ,      
,     GPG. 
 15.1  HTML-     
 
<body> 
Me Private Mail</hl> 
<? 
//      
//   ( 80     443  
echo color red> 
WARNING: you have not connected to this page using SSL. 
Your message could be read by 
?> 
method = post action = 
Your email 
type = text name = size = 38Xbr> 
<input type = text name = title size = 38xbr> 
Your 
<textarea name = body cols = 30 rows = 10> 
</textareaXbr> 
<input type = submit value = 
</body> 

 15.      MySQL 
 15.2  PHP-   GPG   
  _ 
<? 
= 
// gpg,   
//      nobody 
//  
$infile = 
= 
//    ,  
$fp = 
$body) 
//    
= -a \\ 
Welling \\ 
-o $outfile 
  gpg 
//    
{ 
$fp = 
{ 
$result = -1; 
} 
else 
{ 
//   
$contents = ($fp, filesize 
//     
$title, $contents, "From: 
echo Sent</hl> 
<p>Your message was encrypted and 
<p>Thank 
if 
{ 
echo 
<p>Your message could not be encrypted, so has not been 

298  3.      
      ,    -
.       
 
  ,       GPG.  
    nobody 
       
.    ,    .   -
      ,   ,    
.    'pgp',      
,    . 
 
= - 
Welling 
-o 
       gpg.      -
.      , GPG  ,  
    
 
        -
 
 ,  ,  ,     
  ,     . 
    ,     -
  ,       -
      .  ,  Web- -
     ,    . 
          
   . GPG    
,     ,       -
  ?       GPG  
 Web-,      ,  
  . 15.5. 
 
 
1 
Web- 
2 
 
 
3 
 
 
 
 15.5  ,     

 15.       MySQL 
          -
  .       Internet, -
      . 
     ,   -
  Web-.         
.    SMTP-     
 .         
POP         .   -
 ,    . 
   . 15.5   1, 2  3.   2  3 -
       GPG   -
 ,     .    1   
  ,       HTML-. 
   ,       , -
        .   -
   ,  SSL. 
        443,  -
.     SSL  .    -
   SSL,    . 
      ,     
-.        URL,   -
 SSL.  ,    ,   
 ,       .  , -
 ,    ,    -
.        action  . 
    : 
method = post action = 
   ,      SSL--
,      SSL: 
method = post action = 
     URL,   ,   -
    SSL,         
         . 
    ,       SSL, 
    .         
  ,   ,    . -
       HTML-,   -
      . 

300  3.     
  
 SSL  3.0    Netscape: 
          -
 . 
  
        -
.       , -
        Internet,    
   . 

 
 
  
16 
17 
18 
19 
20 
21 
      
    
  
   
 
    
    

16 
  
  
  
 2       Web-
    .    -
   ,   
    Web-. 
 : 
     
     
       
     
     
      , -
   . 
,     
    -  -
 Web- (,    ) 
      
.       -
     -
     .    
      , 
         
 6. 
        -
 ,     -
. 
     
       
HTTP      -
 .        

 16.       303 
   HTTP-      ,   -
     .        -
 HTML-. ,   ,   . 16.1. 
 16.1 
  HTML-, 
   
 ,   
   
f 
: 
| 
Upload new news files 
this ffle: 
a 
 ,        . -
   Browse ()       -
 .  ,         
    .      . 
            
 Send File ( ).     ,    
 
HTML-    
          
 HTML-. HTML- ,   . 16.1, 
   
 16.1 upload.html  HTML-      
<head> 
 upload files</title> 
</head> 
files</hl> 
Upload this 
<input 
</body> 
   ,     POST.   -
 PUT,     NetScape Composer   
 GET    . 
    . 
      
data",     ,     -
  . 

  4.    
          
 .         : 
<input 
      , -
      ( ). 
            -
 : 
  name ( )   ,    -
   ,          -
    -. 
 PHP-     
 PHP-      . 
         , -
  Web-   .       -
,    ,   . 
 HTML-     PHP  -
 : 
       Web-. 
       . 
      . 
     , text/plain 
(/)  
        
 
 
 
 ] 
     ,     - -
 .       ,  -
            -
 . 
        ,  
   ,     ,     -
 .       16.2. 
 16.2 upload.php  PHP-  ,    
HTML- 
</head> 
<body> 

 16.       
if 
{ 
echo "Problem: no file 
} 
if ($userfile_size==0) 
echo "Problem: uploaded file is zero 
if != "text/plain") 
{ 
echo "Problem: file is not plain 
exit; 
} 
if 
{ 
echo "Problem: possible file upload 
= /home 
if ( 
< 
echo "Problem: Could not move file into 
exit 
echo "File uploaded 
$fp = 
$contents = fread ($fp, filesize 
$contents = 
$fp = f open ($upf ile, 
fwrite($fp, 
echo "Preview of uploaded file 
echo 
echo 
?> 
</body> 
<? 
//    . 
//   
//       . 
function { 
if = 
= ' 
} 
.=  
/*       */ 
return == 
 ,        -
  .       -
,  ,  , .    -
        
  . 

306  4.    
   . 
 ,       -
  "",    .     
  (  ,    
 )       ( 
  
        ,    
       . 
     ,     
 .       -
   Web-        -
 ,   - . 
   ,     strip_tags()  
 HTML-  PHP-     
,     ,     
   . 
  ()      . 16.2. 
 16.2 
   
 
,   
    
:  
Uploading file... 
He 
  
Preview of 
  
2nd 2000 - Corporation their Initial 
Offering. Analysts confident the company's shares the first day of 
recent deals NASA. 
  2000 .    ,    -
          
.      -
         
BUGTRAQ,  ,   
         ,   
       /etc/passwd,    
     4.0.3.     -
   4.0.2,        -
  . 
         
          
   .      -
        ,    
 ,        , 
   Web-.       

 16.       / 
    ,    - 
     . 
   
           
. 
         -
.        . 
            
,   ,     
     .    , -
      .   -
      ,    ,   
  .        "-
" . 
   NT    Windows       
    . 
       ,    
    ,   -
  .       -
      -
    . 
      ,    -
    .       -
          -
,    .     -. 
            
. 
     
        
      . 
             -
. 
   
 ,        
.       .  -
 16.3    . 
 16.3 browsedir.php -       
 
<head> 
<title>Browse Directories</title> 
</head> 
<body> 

308  4.    
= 
$dir = 
echo "Upload directory is 
echo "Directory 
while ($file = 
{ 
echo 
echo 
?> 
</body> 
    closedir()  
    .     
  fopen(),   ,   ,   
: 
$dir = ($current_dir) 
      ,   fopen(), 
  . 
    ,         
    .     -
   false.    ,    false  
      "",     ,  -
  .    - , 
        ,    -
 . 
     ,   
closedir($dir)   ,    fclose(). 
       . 16.3. 
 16.3 
   
   
,    
. ( )  .. 
(  ). 
   
   
Browsing 
Upload directory is 
Listing. 
   ,    -
 () . 
           
     . 

 16.       
       
 .   handle  path,    read(), close()   
 ""   . 
     
      -
   . 
 dirname($path)  basename($path)   , -
, ,    .      
      ,    -
       . 
          -
  ,    .    -
  diskfreespace($path).        -
   ,          
(Windows)     (UNIX),    . 
   
        . 
  rmdir() , ,     
. ,      ,   -
 . 
    ,      
.           
(  )     , : 
, 
         -
.        AND () -
    ,    ,  -
 umask. ,  = 022,  , 0755. 
        ,  
  umask: 
= umask 
        
  umask.    umask  ,  
 ;   ,      -
  umask. 
  : 
 
    . 

  4.    
    
,         
,     Web-,     .   -
        ,      -
 . 
    
    ,     : 
($file = 
{ 
echo href=\ 
} 
   filedetails.php ( 16.4)   -
   . 
     :   -
   ,    fileowner()   Windows   
 . 
 16.4 filedetails.php         
 
<head> 
<title>File Details</title> 
<body> 
<? 
= 
$file = //     
 
echo of file: 
$file = 
echo 
echo "File last accessed: F Y 
echo "File last modified: F Y 
= 
echo "File owner: 
$group = 
echo "File group: 
echo "File permissions: 
echo "File type: 
echo "File size: 
echo 
echo "true" 
echo "true" : 
echo "true" : 
echo . "true" : 
echo "true" : 
echo "true" : 
?> 
      16.4   . 16.4. 

 16.       
 16.4 
  
.  
,   
  
. 
Details of file: ipo.txt 
File data 
File 23 2000 
to 23 2000 
File 
File group: 
File 
fie 
File bytes 
File 
false 
true 
Jink: 
true 
   ,     ,   -
  16.4. 
  ,       
,    . (      , 
  
    , , -
     .    -
,         . 
        -
 (      )     ,    
     . 
 fileowner()  filegroup()  , , 
       .   
     ,  -
, ,  posix_getgrgid().    -
   uid  gid,     -
       ,  ;   
   . 
 fileperms()     .    -
    decoct()   , -
    UNIX. 
      .  
  : fifo, char, dir, block, link, file  unknown. 
 filesizeQ     . 
   is_dir(), is_executable(), is_link(), 
is_readable()        , 
   true  false. 
        
stat(),   ,   ,  
 .    lstat()   -
 . 

  4.    
     -     
,     .   -
       ,    
() 
   .       
  ,          -
,     . 
  
      ,      
. 
 group), permissions)  user)  
      UNIX.        Windows--
. , ,      true. 
 chgrp()    ,     
. ,    ( ),    
 ,    root. 
       . -
     chmod  UNIX    -
   "",   , : 
     .     
,   root,   . 
,     
     ,    
. 
             
      .     
 touch  UNIX.   : 
int (string [int 
      ,     
      ,     (  
 ).          -
 .    ,  . 
 unlink()     ( ,   
   delete).      : 
   ,     Win32.  Windows  -
     
      ()  rename(): 

 16.       1 
, ,      ()  -
 16.2. 
       ,  
   .       . 
        ,   -
        , 
        .  , 
           
   ,    . 
  
           -
. 
  , ,   Web-   
     .  ,     
          
,      . 
      Web-.    
. 
1. 
  (): 
exec (string [, array result int 
    ,   , -
: 
 ()    . 
      . 
   result,    ,   
   ,   return_value    
. 
2. 
  
void passthru (string command [, int 
     .  ,  
      , . 
   . 
  ,     (). 
3. 
  
string system (string command [, int 

 4.     
      .   -
      (      -
 ),       
       ( 
 )   false (  ). 
   ,     . 
4.    
      1.  ,    -
 . 
      . 
    .     -
    - . 
  16.5       -
       . 
 16.5       
  _ 
<? 
echo 
//  exec 
foreach ($result as $line) 
echo 
echo 
//  
echo 
//  system 
$result = 
echo 
 
$result = 
echo 
echo 
           
 ,    . 
     ,  , 
      escapeshellcmd(),   
 - ,     .   -
  : 
  :  
    ,    . 
      : getenv(),   -
,  putenv(),   . 

 16.      
,       ,   -
 . 
         
      ,    . , -
 : 
 URL- ,       
. 
       putenv(): 
$home = 
putenv 
          CGI  
: 
  
         
,        -
  UNIX. 
  
  17          
    ,   ,   -
 .      . 

 
   
  
     , -
      
Internet.        -
    .   
  : 
    
     
   Web-  HTTP 
     
  FTP 
      -
  cURL 
   
     
  . ,   -
   -: ,  , 
   .    
    . 
     ,  
     -
  . HTTP,    -
 (Hypertext Transfer Protocol),   -
 Web-. FTP,     
(File Transfer Protocol),    -
    .   -
 . 

 17.        1 / 
    Internet   ,  RFC 
for Comments,   ).    -
 Internet Engineering Task Force (IETF).  RFC  -
  Internet.     Web- RFC Editor   
       ,  
RFC      ,    
.   ,  ,      -
. 
   , , RFC2616,   -
   RFC822,     
Internet. 
     ,     -
.         SMTP, 
    POP  IMAP,   Web-  HTTP 
      FTP. 
    
          -
 mail().      4,     -
   .        SMTP 
(Simple Mail Transfer Protocol,    ). 
   mail()  ,  -
      .   27  -
  HTML MIME,    (Richard Heyes)  -
 HTML-,    . SMTP  
   .  IMAP (Internet Message Access Protocol, -
     Internet,   RFC2060)  POP (Post Office 
Protocol,  ,   RFC1939  STD0053)   
    .       
. 
       , -
  ,    ,  POP,   
          -
   . 
   IMAP.       
    POP  NNTP (Network News Transfer 
Protocol,    ). 
  IMAP      26. 
  Web-  NTTP 
    Web    ,  
        .  -
   .    . 
,  ,    ,     
   .       
,    ? 

 1   4.    PUP 
 ,    URL,     
.    ,  -    
,          
 . 
    ,     -
  NASDAQ (    -
  ).        
 Amazon.com. (   ,   -
  .)     17.1. 
 17.1 lookup.php       
NASDAQ,   ( ,    
)   _ 
<title>Stock Quote from 
</head> 
<body> 
<? 
//     
Quote for 
//  URL   
= 
if (!($fp = 
{ 
echo "Could not open URL" 
exit 
} 
= fread($fp, 
//     
$pattern = . 
if $contents, 
{ 
echo was last sold at: 
echo 
} else 
{ 
echo "No quote 
//   
echo 
information retrieved from 
. 
js F Y g:i a 
?> 
</body> 
       . 17.1. 

 17.        
 17.1 
   
  
NASDAQ  
. 
. 
Stock Quote for AMZN 
sold at $ 
retrieved from 
 --' 
        ,  -
 . 
  ,         2,  
,         URL.    
   .   fopen() 
$. = r) 
       URL.     
   URL   : 
$contents = fread($fp, 
 ,        .  
    ,      
  . 
    Web-     
         -
 
$pattern = (\\ \ ] +\\ . [0-9] +) 
if 
{ 
echo was last sold at: 
echo 
 ! 
      .    
      . 
        
,       .   -
     (Philip Greenspun)   
Bill Gates Wealth Clock (   ): 
     .    -
   U.S. Census Bureau (   ).  -
    Microsoft,   ,  -

  4.    
 ,    ,      -
    . 
  :    ,   -
 ,    ,    .  -
    ,      -
 . 
    ,    
 , , ,  ,   
  URL.        -
    ,    URL, , , 
  .    : 
= 
    
   "" ,    -
   , IP-   . ,    
     URL,   -
       .   
         -
  . 
 HTML-         -
 17.2. 
 17.2  HTML-    
<head> 
your site</title> 
</head> 
<body> 
URL: size=30 
Email contact: <input size=23Xbr> 
<input 
</body> 
            . 
17.2. 
 17.2 
    
 ,  , 
 URL   
 , 
  
  
     
 . 
Submit site 

 17.       321 
   Submit ()     -
,  URL    ,  ,     
      .   , -
  ,      . 17.3. 
 17.3 
    
   
     
    
    
,    
  
. 
Site submission results 
Host is IP 
Email 
AH 
you for 
It visited one of our soon. 
,  ,       
 PHP       -
 17.3. 
 17.3     URL    
<title>Site submission 
<body> 
<hl>Site submission 
//  URL 
$url = 
$host = 
= 
echo "Host URL does not have valid IP" 
echo "Host is at IP $ip 
//    
= 
= 
if 
echo "Email address is not at valid 
echo "Email is delivered via: 
as 
echo 
//      ,    
echo submitted details are 
echo "Thank you for submitting your 
will be visited by one of our staff members soon." 
216 

  4.    
       
?> 
    . 
   URL  parse_url().   -
      URL.   -
     (scheme),  (user),  (pass),  (host), 
  (path),  (query)   (fragment).    -
  ,    ,    URL. 
  
    
 scheme: 
 user: nobody 
 pass: secret 
 host: bigcompany.com 
 port: 80 
 path: 
 query: variable=value 
 fragment: anchor 
      ,    
 : 
$url = 
$host = 
    IP- ,     DNS-, 
     IP-,   -
   false   : 
$ip = 
     ,   gethostbyaddr(), 
  IP-     .     
 ,       ,   , 
   .   ,     -
 . 
  ,     . -
            
$email = 
$emailhost = 
  ,  ,      .  -
    

 17.        
    MX (Mail Exchange,  )   
  ,   
-   DNS      ,    . 
,    MX   ,   . -
  ,    . (   , 
   ,      .)   DNS  
   , ,    . 
    ,       
   -    . 
        
      true,     
-   DNS. 
 FTP 
File Transfer Protocol (  ),  FTP,   -
     .  ,    -
     ,    HTTP-,  
        FTP-.  ,  -
     ,   FTP. 
      .     
  UNIX,    PHP- configure  
    make.    
  Win32,    
  "Windows Extensions" (" Windows")  ( -
       .) 
 FTP        
          
.          -
  Web-       .   17.4 
    ,  FTP-   -
  . 
 17.4 ftpmirror.php        
 FTP- _ 
<head> 
<title>Mirror 
</head> 
<? 
//      
$host = 
$user = 
$password = 
= 
$localfile 

  4.     
   
= 
if 
{ 
echo "Error: Could not connect to ftp 
exit; 
} 
echo "Connected to 
//    
= $user, 
if (!$result) 
{ 
echo "Error: Could not log on as 
} 
echo "Logged in 
//        
echo "Checking file 
if 
{ 
$localtime = 
echo "Local last updated 
echo 
echo 
} 
else 
= 
if >= 
{ 
//          
//  " " 
echo "Can't access remote file time 
//   
} 
else 
{ 
echo "Remote last updated 
echo 
echo 
if > 
{ 
echo "Local copy is up to 
exit; 
} 
//  
echo "Getting file from 
$fp = ($localfile, 
if (!$success = $fp, $remotefile, 
{ 
echo "Error: Could not download file"; 
} 
echo "File downloaded 

 17.       
//    
?> 
</body> 
      . 17.4. 
 17.4 
   
   
 FTP , 
   
     
,   
. 
Mirror update 
Connected to flp.cs.nfflt.edu.au. 
in as 
Checking time,.. 
fflelastupdated 
Getting ffle from 
downloaded successfully 
 
    .     : 
$host = 
$user = anonymous 
$password = 
= 
$localfile = 
       -
,     ,    , 
    . 
      (anonymous 
login), ..   ,      
 .   ,       
     ,     
,    .     . 
    ,   .  -
          
 Term SSH   SSH  Windows. (SSH  secure shell ( 
 ).   Telnet,      
 .) 
  ,      
   . 
   ,     -
 . 
       ,   
   FTP      : 
1.    
1.  (       ). 

 4.    
3. ,     . 
4.  ,  
5.  
   . 
   
    
ftp hostname 
   Windows  UNIX.        
  : 
= 
if 
{ 
echo Error: Could not connect to ftp 
exit; 
} 
echo Connected to 
    ftp_connect().     
,       ,   false, 
   . ,     
 . (   .)     ,   
   21,  FTP-. 
  
          
   .     ftp_Iogin(): 
@ $result = 
if (!$result) 
{ 
echo "Error: Could not log on as 
exit; 
} 
echo "Logged in as 
    :  ( 
 ftp_connect()),    .    -
,    true,      false. 
 ,        @,  -
  .   ,  ,     -
,      .  -
   ,         
   ,     . 
,     ,   FTP- -
  ftp_quit();    . 
    
     ,   , 
   ,       , 

 17.       I 
  ,     .   -
  .   ,    . 
         
  , , ,   .    
,        -
 ,       
   ,    0, ..  
    ""      
 : 
echo "Checking file 
if 
{ 
$localtime = 
echo "Local last updated 
echo 
echo 
else 
(  ffle_exists()       2  16.) 
         -
    .     
$remotetime = 
          -
 .         -
 UNIX,  -1,   - .   -
  ,         
.       "",  
       ,   
   : 
if >= 
{ 
//    ,     
//  " " 
echo access remote file 
// ,    
} 
else 
{ 
echo "Remote file last updated 
echo j-M-Y", 
echo 
    ,        
  : 
if {! > 
{ 
echo "Local copy is up to 

328  4.    
  
        : 
echo "Getting file from 
$fp = 
if = $fp, $remotefile, 
{ 
echo "Error: Could download 
exit; 
} 
fclose($fp) 
echo "File downloaded 
   ,       
    ftp_fget(),     -
  .     .    
          
   .     
  FTP     : ASCII  . 
 ASCII      (.. ,  
  ASCII-),         -
.        
    .  , -
           -
  ftp_fget().     zip-, -
   
 ftp_fget()   true,    ,  false,  
 .      -
 ,    . 
        
 ftp_fget()       -
ftp_get(),    : 
int ftp_get (int string 
string int mode) 
    ,  ftp_fget(),      
.      ,     
,    . 
 ,       mgct, 
     .     
  ftp_fget()  ftp_get(). 
 
       
    

 17.       
   
         , 
   ,  ftp_fget()  ftp_get(). 
  ftp_fput()     : 
int (int ftp_connection, string 
int fp, int mode) 
int (int string 
string int mode) 
      
  - 
  ,         FTP, 
     .    -
      ,  .  ,  
      ,   -
   , , . 
         -
   php.ini.      30 .  -
   ,   -   -
.      FTP,      
      ,    -
 . 
 ,       -
,       -
     ,     . 
, 
   90     . 
    FTP 
         FTP. 
         -
 : 
int string 
         -1   . 
    . 
       -
 .      ,   
        
      FTP-    -
   : 
$listing = 
foreach ($listing as 
echo 

 4.     
         -
 ftp_nlist(). 
      ,   
    FTP-,   
FTP,          
   mget (multiple get),   -
     ,     . 
    
   cURL 
  (   4.0.2)   ,    
  cURL,   Client URL   libcurl,  
 (Daniel Stenberg). 
           
   HTTP.      , 
 ,    FTP-,  FTP-. 
 cURL     FTP, HTTP, 
Gopher, Telnet, FILE  LDAP.  ,   -
     HTTP POST  HTTP GET, -
     FTP  HTTP,   -, -
 cookie-       
HTTP. 
 ,   cURL     -
 . 
  cURL      libcurl, -
       configure   
 path        -
 .      
 ,        cURL   7.0.2-
beta. 
  cURL      . 
        
1.   cURL    
2.         
  ,  URL, ,   
    ,   URL. 
3.   ,    curl_exec(),  -
 . 
4.   cURL    curl_close(). 
,      URL  ,  
curl_opt().       . 

 17.       
    cURL    
    ,  HTTPS ( fopen()  
   ) 
   ,      HTML--
  POST 
  ,       -
    
      , , ,  
    . 
,    17.5,    Equifax Secure Server 
 HTTPS         Web-. 
 17.5     _ 
<? 
transfer with 
$outputfile = 
$fp = 
echo cURL 
$ch = 
echo "Setting cURL 
($ch, 
echo "Executing 
echo "Ending cURL 
curl_close 
  .        -
  fopcn().     ,   -
 . 
    cURL    
= 
    cURL.     ,  , 
 ,      URL.  ,    -
  curl_setopt(),      : 
curl_setopt ($ch, 
curl_setopt $fp) 
 curl_setopt()   .     -
 ,     ,     -
 . 
     .    URL,   -
  .      -
  ,     ,   . 
   ,         
  , .        . 
    cURL   : 
curl exec 

3 3  4.     
       URL,  -
     ,    
     cURL  ,    : 
curl close 
      . 
    Snoopy,      
    cURL   Web-. 
  
      , ,   ,  
     . 
           -
 RFC   
         
World Wide Web (World Wide Web Consortium): 
 TCP/IP    .   -
. 
 Web- cURL        
 cURL.     -: 
  
  18   PHP-      -
.  ,   ,  ,  -
   MySQL  . 

18 
   
 
      
  ,      -
 .     -
   MySQL  , UNIX   
  ,    HTML-. 
     : 
       
       MySQL 
    
    
    
  
  1     
date()         
.      PHP- -
  . 
 
 date()   ,   -
  .   -
   ,  , , -
  UNIX.     ,  
 date()     .  
  ,  . 
   : 
F 
     "31th July 2001". 
 ,   date(), 
  . 

  4.    PHP 
 18.1   PHP- 
 
     ,    , "am"  
     ,    , "AM" 
 
 Internet- Swatch    .     
    http://www.swatch.com. 
d         .     "01" 
 "31". 
D      .     
()  "Sun" 
F    .     "January" ()  
"December" (). 
g      .      "12". 
G   24-    .     ""  "23". 
h   12-    .     "01"  "12". 
   24-    .     "00"  "23". 
i    .     "00"  "59". 
I    ,    .   
   ,    "1",   "". 
j        .      "31". 
I     .     "Monday" 
()  "Sunday" (). 
L  ,    .   
 "1",     ,  ""    . 
       .    
"01"  "12". 
     .     "Jan" ()  
"Dec" (). 
       .     "1"  "12". 
s    .    "00"  "59". 
S       .    
     ,    . 
t     .     "28"  
   ,    , , 
U    1  1970 .   ;     
 UNIX  . 
w     .     "" ()  "6" (). 
    , , "00". 
Y    , , "2000". 
z     .     ""  "365". 
Z      .      
"43200". 

 18.     
    UNIX 
   date()    UNIX. 
 UNIX-       32- 
  ,    1  1970 .  .   -
   UNIX.        , 
  ,  . 
  UNIX          -
,        2000-  (Y2K),  -
 ""     .   ,  -
   2038 .    .   
    ,  ""    
   (32 ).     2038 .    
   . 
     Windows-,    date()   
PHP-      . 
          UNIX, -
      : 
int minute, month, 
int day, int year [, int 
     , is_dst,  -
,      .      
    ,  0   ,  -1 (  ), 
  .   ,       
 . 
 ,       
   .     
.     ,   ,    
 0. ,        . 
     . ,  -
 
= 
   UNIX     .    , -
 ,        
= 
       -,    -
.    0  69     2000  2069,  
 70  99     1970  1999. 
  
   ,    , -
 getdate().    : 
array (int 
    ,     -
 ,     ,    . 18.2. 

   4.    
   -,   
 
seconds   
,   
hours ,   
   
wday  ,   
 ,   
year ,   
yday  ,   
weekday  ,   
month ,   
   
       checkdate().  
    ,  .  
  : 
int checkdate (int month, int day, int year) 
 ,       0  32767,     1 
 12,        .   -
   . 
, 
checkdate(9, 18, 
  true, a 
31, 2000) 
. 
      MySQL 
    MySQL    ,     -
.      ,     MySQL  -
   . ,  31th of July 2001    2001-07-
31  01-07-31. ,   MySQL,     . 
,    MySQL    -
 .     . 
      MySQL       
    date(),    .  -
   ,         -
      MySQL. 
      MySQL,    
    
      ,  
   .         -
 MM-DD-YYYY (//)    MySQL  

     
YYYY-MM-DD (//).      
: 
SELECT %d 
FROM 
      ,     
,    .     
MySQL      . 18.3. 
 18.3  
  
,   
%W  ,   
 ,      (, 1st) 
, 4-  
, 2-  
%  ,  
 ,     
%  ,     
,     
% ,     
, 3-   
 ,   
  24-     
  24-     
   12-     
      
,     
  12-  (hh:mm:ss 
  24-  (hh:mm:ss) 
 %s ,     
AM   
 ,   0 ()  6 () 
  ,    -
    UNIX. , 
SELECT 
FROM tablename; 
     UNIX.       -
  . 

    4.   
      UNIX  -
  ,         .  
        UNIX. 
   
           
       UNIX.   
   
 18.1 calc_age.php         
//     
$day = 
$month = 9 
$year = 
//      // 
= mktime $month,  
UNIX    
=   UNIX    
= -
$age = floor / (365 * 24 * 60 * //  
//   
echo "Age is 
          .  -
        HTML-. 
         -
       : 
= mktime 
= //    UNIX    
      ,     -
: 
$ageunix =  
          
   ,   .     -
,  ,   .     ,   
   .        
floor(),    , , 20     
   : 
$age = floor ($ageunix / (365 * 24 * 60 * // 
//    
 ,     ,    -
     UNIX (.. 32- ). 
   
    ,    -
   .    
 ,     . 

 18.     
      .  15 -
 1582 .       5  1582 .  
 .        
.         , 
     20- . 
, ,      ,  ,   -
    .        UNIX.  -
  ,    4000   ..       -
,         .   
       (JD),      
. 
       
    
     ,   -
     : 
int gregoriantojd (int month, int day, year) 
string julianday) 
       : 
$jd = gregoriantojd (9, 18, 
echo 
          
(//). 
         
 , ,    ,   
  UNIX. 
  
             
MySQL,        Web--
: 
       ,   
    : 
 ,     : 
  
           
.   19       -
  . 

 
 
      - 
  .    
 ,       
    -
  GD.    ,   -
      
   . 
    : 
      
   
   
       -
 
      
   :   Web-
        
     MySQL. 
    
 
      -
  gd,      
 1.6.2       4. 
    PNG.   
 JPEG,    jpeg-6b  
  GD   -
 jpeg.      

 19.   
     
,  ,    . 
    TrueType-  -
 FreeType,      4;       
   TrueType  PostScript Type 1  -
     
         
  
 GD   JPEG, PNG  WBMP.  GIF -
  .      . 
JPEG 
JPEG (  Joint Photographic Experts Group (-
    )    .  -
,    JPEG,    JFIF,  -
   ,   JPEG. 
      ,   ,   JPEG 
          
    .       -
, ..      .  -
      ,  -
      .       
 ,    ,   . 
  JPEG/JFIF     JPEG: 
PNG 
 PNG (  Portable Network Graphics ( -
 ).        GIF (Graphics 
Interchange Format,    )  ,  -
   . Web- PNG     " -
    ".    ,   -
  ,  ,      , , 
,     Web-    ,   -
   GIF. 
       ,  GIF,  
, -   .     
      MNG,   
    . 

 4.     
   PNG      : 
WBMP  Bitmap (    ).  
       .   
GD   ,         -
  . 
GIF 
GIF  Graphics Interchange Format (   -
).      ,    Internet  -
 ,  ,    . 
  GD    GIF? 
   ,       1.3.  
  PNG      GIF,  -
  GD  1.3  Web- 
, , ,   GD    
      .      GIF -
   . 
  ,  GD     
GIF.   GIF    Ziv Welch),  -
 UNISYS.  ,      
 GIF,   UNISYS  .  , , 
 Adobe,  , , Photoshop,    
GIF-.     ,      
,      .  ,    
 Web-    GD   GIF,   -
,     UNISYS    . 
 -  ,   GIF   -
  ,   UNISYS   . -
,       Internet.    
Internet        .  -
    (   )   UNISYS 
   Burn Gifs ("  GIF-") 
     ,      
   ,         
  PNG     GIF. 
  PNG    ,    
 LZW  19  2003 .,     -
. 

 19.   
        : 
1.  ,    . 
2.        . 
3.   . 
4.  . 
       , -
   
 19.1      
  () _ 
<? 
// 
$height = 200; 
$width = 200; 
$im = 
= 255, 
$black = ImageColorAllocate 0, 0, 0) 
// 
0, 0, 
0, 0, $width, $height, $white) 
4, 50, 150, "Sales", 
//  
Header 
//   
     . 19.1. 
 19.1 
   
  ,  
   
  . 
' 
Back . Slop i 

 4.    
     . 
  
          , -
   .      .  
      ImageCreate(),     -
: 
$im = 
  ImageCreate()    .    -
   ,    .   -
  . (     
.) 
       ,    
  ,     -.  -
    ,       
 -
      , , 
$im = 
,         
 ,     . 
      
         . 
   ,     . 
,  ,         
 ,   .    -
 ,        -
  .     ,     
 .       ,   -
  . 
    ,    
      ,   -
 (RGB)   . 
    :   .   
  
$white = ($im, 255, 
= ImageColorAllocate ($im, 0, 0, 0) 
   ,     -
     . 
,     ,    
        , ,   
. 
    : 
   
          

 19.   
  
       
    .  . 
    ImageFilI()   : 
, , 
     ,  -
   (  )   . 
 ,         
 ,    =0, =0.    -
   y=$height.     -
   ,     ! 
   (0, 0)      
 : 
0, 0, $width, $height, 
     ,   
    . 
     : 
4, 50, 150, "Sales", 
    .    
: 
(int int font, int x, int y, string s, int col) 
   , ,  -
     ,    . 
    1  5.      -
.      TrueType  
        .   -
       TrueType. 
         , 
  ,   ImageStringO   , , 
(   )  .  TrueType 
 PostScript  ,  . 
         , -
   . 19.2. 
 19.2 
   
 , 
   
 . 
  
   
 . 
Normal 

346  4.     
,       ,    
.   ,        -
 "        -
 ,      .    -
 . 
  
         . 
      .      
.    Web-,     -
,     HTML-.     Header(), -
 : 
Header 
     MIME-   ,   
Web-.     HTML   (  ), -
   
text/html 
  ,     . 
     ,   ,   
  HTML.       -
   . 
    HTTP-.    -
  HTTP-.      -
  .      . : 
Header ("Location: 
 ,   Header()    ,  HTTP--
   .   HTTP-   , 
   -  . ,    
echo            
,  ,        -
  Header().      HTTP--
           -
,           . 
         
       PNG.    
,       
JPEG,        GD.  
,     , .. 
Header 
 

 19.   / 
 ,   ,    -
  ,   .   ,   -
    ImagePNG() (     ): 
,            (, 
    ). 
 
      ,   -
 ,   .     
 
     
  
           -
  ,   ,  , -
  ,      .     -
 : 
1.      ,      -
. 
2.     ,     ,   
       <IMG>. 
3.      ,  . 
  1  2   .    3. 
 HTML-    
  : 
<img height=200 
going 
   PNG, JPEG  
GIF ,     SRC 
 ,  . 
     -
   ,   . -
   . 19.3. 
   
   
 
   . -
      -
   Web- -
. 
Sales 
This sales are shown 
Next month show 
'  19.3   
    
  ,   . 

348  4.    
1 
.-! 
Create buttons 
Type button 
Choose color 
Green 
I 
. -
 ..... Slop 
- 
.....  
I 
Home 
 19.4   
     . 
 19.5 ,   
 ,    ,    
  . 
      ,   , 
   ,   ,   -
 ,   Photoshop, GIMP    . 
   ,       -
 . 
 ,   TrueType,     -
.    TrueType-   ,  -
   . 
,  ,   ,    ,   
    .       . -
 ,      , -
  . 
       ,  , 
  .     . 19.4. (HTML-   -
   ,    ;  ,     
CD-ROM   
       Web-. 
,  ,       Web-
  ! 
     . 19.5. 
        19.2. 
 19.2 make_button.php          
   HTML-  
<? 
// ,     
//   button-text  color 
if 
echo "Could not create image - form not out correctly"; 
exit; 

 19.   
//       
$im = 
= 
= 
//   18    
= - (2 * 
= - (2 * 18) 
//   ,      , 
//    
//    ,     
$font_size 33; 
do 
{ 
//       
($font_size, 0, $button_text) 
= //   
$le.t_text = //   
$width_text = $right_text - //   ? 
$height_text = - //   ? 
} while ( $font_size>8 && 
( $height_text>$height 
) 
if ( | | 
) 
{ 
//    
echo "Text given will not fit on 
} 
else 
{ 
//    
//     
$text_x = -
= -
if ($left_text < 0) 
$text x += //    
//   
= //    ? 
+= //     
$text_y -= 2; //    
$white = ImageColorAllocate ($im, 255, 255, 
($im, $font_size, 0, $text_x, $white, 
, 
Header 
ImagePng 
} 
ImageDestroy 

 4.    
     ,    .   
  .     ,    
 . 
 
  19.2    .   
     :   (green- 
  
,  ,   
        
: 
       PNG, 
     .  ,   
      PNG.    -
       
 
    .   -
       ,     
    . 
     
  $button_text  ,  .   
       .  
    ,  ,     -
. 
    .      
 : 
= 
$height_image = 
       .   -
,        .  
        !  -
       18 . 
= - (2 * 18) 
= $height_image - (2 * 18) 
    .    32 (-
, 33,      ),    -
 ,     : 
= 
  ,        -
   ,       : 

 19.   
do 
{ 
//   
($font_size, 0, 
= //   
$left_text = //   
= $right_text - //    
$height_text = - //   
} while ( 
( | | 
) 
     ,   -
 .       -
     TrueType-.     
   TrueType    Image 
      ,  -
   .      . 19.6. 
(0,0) 
 19.6       
.     (0,0). 
      
$ = 0, "arial.ttf", 
    : "   -
   ,   TrueType  
,        , -
 .            (-
  ),     . 
  ,     -
.      . 19.1. 
   
  
 X   
1  Y    
2  X    
3  Y    
4  X    
5  Y    
6  X    
7  Y    

 4.   
 ,     ,  , 
          
. 
,      
.   ,    . -
,     ,       
,     . 
   . 19.6. ,     , 
   .      ,  ""  
.      (descenders). 
       (0,0).  Y  
    ,     . 
 ,       . 
,   ,  ,   X,  -1. 
  ,         
 . 
       : 
$right_text = //   
$left_text = // 
= $right_text  //   ? 
$height_text =  //  
    : 
> ( $font_size>8 
( | | 
$width ) 
    . :     , -
      ,    8. 
:        . 
,          
  ,    : 
if ( | | 
image_wo margins ) 
{ 
//    
echo "Text given will not fit on 
} 
     ,   -
,     .   ,   . 
$text_x = -
= -; 
- ,      ,  
  : 
if ($left_text < 0) 
$text_x +=     
=   ? 
+=  
-=   

 19.   
     , -
  " ". 
    
    .     , : 
$white = ImageColorAllocate ($im, 255, 255, 
      
ImageTTFText $font_size, 0, $text_x, $white, 
    :  ,  
  ,   ,  X  Y  , , 
  ,  ,  . 
      ,      
  ,       -
.         ,    
.  ,        . 
  
       : 
Header 
ImagePng 
    : 
ImageDestroy 
  !    ,     ,  
 . 19.5. 
     
        
.        . 
     ,   Web-. -
      MySQL,      --
   . 
         . 
    ,   Web-   , 
 . 
       MySQL   poll.  -
   poll_results,    : candidate   -
    .       -
   poll   poll.        -
  SQL-,    19.3.   -
      root: 
root -p < 
12 216 

 4.    PHP 
 ,      , -
    MySQL. 
 19.3 pollsetup.sql     poll 
create database 
use poll; 
create table ( 
candidate 
int 
insert into poll_results values 
, 
0) 
grant all privileges 
on 
to 
identified by 
      .    
  vote.html,      19.4. 
 19.4 vote.html      
<head> 
<title>Polling</title> 
<head> 
<body> 
<hl>Pop Poll</hl> 
will you vote for in the election?</p> 
<input Smith<br> 
<input type=radio Jones<br> 
<input 
<input 
      . 19.7. 
    submit,      , 
          -
. 
 19.7 
   
  
,  
 submit 
()   
   
 . 
Pop Poll 
you vote the 
John Smith 
 Mary Jones 

 19.   355 
 19.8 
  
  
  
 , 
  
 . 
1 
|   Slop 
Poll 
tt 
  212    . 
  ,  .     
 ,  . 
     ,    
      MySQL,     
      . 
    ,      -
.       .  1 ( 
  )    
 19.5.1 showpoll.php   1        
   _ 
<? 
       
//     
if = "poll", 
{ 
echo "Could not connect to 
exit; 
//  ,   
{ 
$vote = 
= "update poll_results 
set = + 1 
where candidate = ' 
= 
{ 
echo "Could not connect to 
exit; 
//    , 
//    
= "select * from 

   4.     
if ($result = 
{ 
echo "Could not connect to 
} 
= 
//     
while ($row = mysql_fetch_object 
{ 
$total_votes += 
} 
//   
 1,    19.5.1,     MySQL, -
          
.   ,   ,   
 .  2     19.5.2. 
 19.5.2 showpoll.php   2     , 
   
     
//   
//      
//     640x480 
= 50; //    
= 50; //    
$bar_height = 
$bar_spacing = 
$font = 
$title_size = 16; //    
= 12; //    
$small_size = 12; //    
= //     
//      
$ = + 60; //    
$ = 50; 
$bar_unit = / 100; //  ""  
 
//       
$height = * ($bar_height + + 50; 
  2  ,    . 
     ,  -
  ,     ,   
  . ,   ,    
        . 
   ,  -
    , $bar_height  $bar_spacing  ""  -
  , $font, $title_size, $main_size,   
,     . 

 19.   / 
     .   -
  ,      .  -
        ( X),   -
  ( 
    :     , 
 : 
= / 100; //  "" 
//   
            -
  100,       . 
    : 
$height = * ($bar_height + $bar_spacing) + 50; 
   ,    ,  , -
  .  3     19.5.3. 
 19.5.3   3      
  
   
//    
$im = 
//   
$pink = 
$text_color = 
= 
$bg_color = 
= 
$bar_color = 
= 
//     
//   
//  
$title = "Poll Results"; 
= 0, 
= -
$title_height = -
= 
$title_x = //    
$title_y = ($y -+ // 
//       
$title_size, 0, $title_x, $title_y, 
$text_color, $font, 
//  ,      
//      
$x, $y-5, $, $height-15, $line_color) 

   4.    
  3    ,      
. 
        
     ,  
 .  ,     -
.     X  Y    .  -
, ,       .   
       ,    -
 . 
    
     .   -
     .  ,    -
         -
     . 
           
  ,     . 
 ,   : 
$x, $y-5, $, $height-15, 
         ($, $-5) 
    ($, $height-15),  
          
. 
     .  4    19.5.4. 
 19.5.4 showpoll.php   4      
    
   
//       
//  
while ($row = mysql_fetch_object 
{ 
if ($total_votes > 0) 
$percent = 
else 
$percent = 0 
//   
0, $width-30, , 
if ($total_votes > 0) 
$right_value = votes/$total 
else 
$right_value = 0 
//      
= + ($right_value * 
//     

 19.   
$x, $y-2, $bar_length, 
//    
0, , 
$font, 
// ,  100% 
), 
//   
$small_size, 0, $x+ 
$font, 
//     
$=$+ 
} 
 
*******************************************/ 
  
ImageDestroy 
  4        , -
  ,       . 
  ,      
   
$, $bar_length, 
,  100%,   
$y-2, 
        -
      . 
  ,       .  
 , ,  , ,    "" 
.     ,    -
,     . 
    ,     -
        . 
    
 ,    ,   ,  -
       -
   .       
  .      ,    
  ,    . 

360  4.    
  
     Internet.    
     ,    -
   GD,   PHP-     -
 .   GD    
        -
    Zend  Devshed: 
 ,  ,     
(Steve Maranda),    Devshed. 
  
         
 ,    4. 

20 
 
  PHP 
       
     4. 
    : 
     
 cookie- 
   
   
    
    
,   ,  HTTP -
  "  ".  ,  
      -
    .  -
      , HTTP  
  ,    -
      . 
 ,     
       
   Web-. 
   ,    -
      
        -
   .   -
  .  ,   
   (shopping carts). 
       -
  PHPLib,   , 
      -
.      

362  4.     
        -
.    PHPLib,  PHPLib     
    .    ,   
      ,    -
   PHPLib. 
     
        , -
    .   -
            .  
     cookie-   
,  URL. 
    ,   -
         
.      .  -
, ""   ,   .    
        "" 
  cookie-,   URL,      -
 ,       .   -
        (   -
         ,   
           
  "  "). 
 ,     Web-,     -
   URL.    URL   , -
  ,  ,  ,    
       . 
        -
 ,       cookie--
. 
  cookie-? 
cookie-     ,   -
   .   cookie-   , -
       : 
Set-Cookie: ] 
[secure] 
  cookie-   NAME   VALUE.   -
  .  expires     , 
   cookie-     
(,        , cookie-  -
,  -      ,   ). 
  path  domain       
URL,     cookie-.   secure ,  
cookie-      HTTP-. 

 20.     
    URL,    cookie-,  
.  -     URL,    -
,     . 
  
cookie-     ,   
   : 
int setcookie (string [, string value [, int expire [, string path 
[, string domain [, int 
    ,      
 Set-Cookie. 
 cookie-   
setcookie 
          ( -
  ),        
   "value".        
 
  cookie-      ,  
  .  cookie-     (-
   URL   ),     -
 ,  cookie-   . 
  cookie-      
       
    ,   cookie-    
   (  cookie-   ). 
 cookie-   
  cookie-   :  , 
   cookie-,   ,   -
 cookie-   .    ,     
    (   -
  ). 
      cookie- .    -
  . 
     cookie-,   -
 ,     -
  ,   lifetime, path  domain. 
  : 
    cookie-  . 
        
     cookie-     -
 Netscape: 

364  4.     
   
  cookie-     .    
 cookie-,       -
   . 
 ,     ,    -
    URL.   ,    -
           
   -      , -
  .       SID, 
     ,      , -
  GET: 
          
 ( ,   SID    -
     ,      --enable-
    
     : 
   
    
    
       
,           
,         .  
    . 
  
       , 
   .     . 
 (  )   ,      
 
  ,     .  , 
  .        -
   ,      -
. 
 ,         -
,    . 
    ,      -
   (.  ). 
       ,     
 ,   -   .    

 20.    
    php.ini (   
     ). 
   
          
 ,   .      
session_register(). ,     -
 : 
= 5 
 :      , -
  .       $. 
        . -
   ,       -
    . 
       ,  -
    : 
   
      ,  -
  ,      . 
      .   -
 (.  1),          
  , ,      ,  
       
, 
       GET  POST.  -
     ,     -
  . 
  ,         , 
     (,   isset()  
 ,    ,      
  GET  POST. ,    -
  ,     session_is_registered(). 
    : 
$result = 
  ,     , 
  true  false. 
   -     
    . 
     
         , 
  
session 

366  4.     
  ,      , 
   ,   ,    $. 
           
 (  ,     
      
        , 
   
   . 
   
      ,  
    .      
  . 
         $sess_var. 
,   ,    20.1. 
 20.1       
<? 
$sess_var = "Hello 
echo "The content of \ $sess_var is 
?> 
<a href = page</a> 
         
   . 
,         . -
, ,      ,    -
 .         , -
     .      
    (),  ,   
    
 20.1 
  
 , 
  
: 
 
' 
I 
The content of is Hello world! 
Next page 

 20.    367 
 ,       
   20.2. 
 20.2 page2.php          
 
echo "The content of \ $sess_var ia 
<a href = page</a> 
    ,    
 ,      (. . 20.2). 
     ,   
   .  :   ,   
$sess_var     . 
 ,    page3.php,     
.       20.3. 
 20.3    
echo "The content of \ $sess_var is 
    . 20.3,     . 
     session_destroy()    . 
1 
j 
; 
The content of is Hello world! 
D 
:-" ' -
1 
 20.2   , 
     
  
The of is 
 20.3    
   . 

368  4.     
   
          -
,       php.ini.  .  -
         . 
 20.1    
 
session.cookie_domain 
lifetime 
session.name 
cookies 
 
 ()   . 
180     
 ( ). 
     cookie- . 
   
cookie-     
.   0     
 . 
/     cookie- . 
PHPSESSID  ,     
   cookie-. 
     .  
   ,    
   . 
     .   
      
     
1 ()     
 cookie-   . 
    
  
        . 
 , ,       
  ,       
.     ,    -
          
MySQL     . 
        24,  -
       . 
       ,   
  14.         
  ,    ,    -
 14.3   14. 
    . , authmain.php,  -
       Web-. , 
     ,  

 20.    369 
  . , logout.php,   -
  . 
 ,    ,   . 20.4.   -
,   
       .  -
,         Members,   -
 ,   ,   . 20.5. 
 ..... 
; 
Home page 
You are logged in. 
1 
Userid: 
Password: 
Members 
i! 
i 
Members only 
You are not 
logged in members may see this page. 
Back to main 
 
 
 20.4  
      
  
 20.5   
  ,   
    . 
      
       (  -
:  :      14),    -
     Members,   ,    . 20.6. 
    .      -
 authmain.php,    20.4.     . 
 20.4 authmain.php      
if ($userid && $password) 
//       
= 
= "select * from auth 
. and 
$result = 
if >0 ) 
, 
//     
//    
$valid_user = 

 I  4.    PHP 
<body> 
<hl>Home page</hl> 
<? 
if 
echo are logged in $valid_user 
echo 
} 
else 
{ 
if 
{ 
//  
//    
echo "Could not log you in"; 
} 
else 
{ 
//      
//    
echo "You are not logged 
} 
//   
echo 
echo 
echo 
echo type=text 
echo 
echo 
echo colspan=2 
echo 
echo 
<a section</a> 
</body> 
    ( 
 ) ,   
:     
      -
. 
    
   
     -
:  -   
  ,  -
     
$valid_user,   -
 . 
       
? ,  
     
$valid_user,    -
. 
 
 
Members only 
You are logged in as 
Members only content goes here 
Back main 
 20.6    
   
   ,   
 

 20.    
          if   
         
  ,       .    
  ,       : 
echo action=\ 
echo 
echo 
echo 
echo 
echo 
echo colspan=2 
echo value=\ "Log 
echo 
     (Submit),    
     .         -
  ,   (    
   ,    : 
($userid && $password) 
( 
//      
= 
= "select * from auth 
. and 
$result = 
       MySQL      
.        ,   -
      -
.  ,  ,     , ,   -
. 
if ($result) >0 ) 
{ 
//   , 
//   
$valid_user = 
  ,    ,     
    .     -
,   ,   ,       : 
if 
{ 
echo "You are logged in $valid_user 
echo 
} 
          - 
  ,      ,   -
 $valid_user,    ,      : 

3 /  4.    
if 
{ 
//      
echo "Could not log you 
} 
    ,   
      URL,  : 
  , ,  .      
Members.       20.5. 
 20.5 members_only.php     Members    
Web-   
<? 
echo 
//    
if 
{ 
echo are logged in as 
echo only goes 
) 
else 
{ 
echo are not logged 
echo logged in members may see this 
> 
echo to main 
    . ,         -
 ,      ,  -
      -
 ,       
,      ,      
. 
     logout.php,    
  .      20.6. 
 20.6 logout.php       
     
<? 
= //   , 
//   
$result = 
?> 
<body> 
<hl>Log out</hl> 
<? 
if ) 
{ 
if ($result) 

 20.    PHP J / 
       
echo "Logged 
} 
else 
{ 
//        
echo "Could not log you 
else 
{ 
//   
//  -     
echo "You were not logged in, and so have not been logged 
  ,     -
 .   ,    ,  -
  $valid_user   .     -
    :    ,     
      ,     -
. 
 ,        -
   ,      . 
  
       4,    -
     PHPLib.    -
  ,      PHPLib    
cookie-.          URL,  -
     : 
  
      . 
    ,      
 ,        . 

  
  
        
,     - -
 . 
 : 
    
  ,   , -
 eval() 
  : die  exit 
 
       
     
    
     
   
,  ,    
 ('       (\)  
   .   
    
echo "color = 
     .   -
  , ,    
 ,  . ,   
"color = 
  
echo = 
 . 

 21.    PHP / 
      ,      
 . 
    
insert into company values Auto 
      MySQL. 
      -
    ,  ,   -
  
     ( "")   
    .       
        GET, POST, cookie-
   . 
  magic_quotes_gpc     
  GET, POST   cookie-. 
    magic_quotes_gpc     "Bob's 
Auto Parts",    Auto Parts",    
 . 
  1  0,    -
      ,   
   ,   . 
      
,       . 
      
   1  0.   
         -
 
   -
 
 eval()     -. 
,  
( "echo 
  .       ,  
echo 
  ,    eval()   . 
,       ,      
  eval(),      (   ),   
       . 
 , eval()       -
 .     ,   -
,  ( )  ,   -
:     ,     regexp, 
    eval(). 
 ,      -   
 ,      eval(). 

 /   4.    PHP 
 : die  exit 
         exit. -
,    : 
exit; 
   . 
       die().  
           
.      Perl. 
       exit: 
ending 
     or  ,   -
 , ,       : 
or not execute 
     ,    -
   : 
{ 
echo "MySQL error 
echo 
) 
or 
    ,     
. 
          
      . 
 
    ,     
    ,   ,      
      .      -
        . 
        -
. ,    ,     -
 .       
,     HTTP-. 
  ,         
    .      :  
   : 
= 
 ,      , 
  .        -
. 
,       employee, -
 : 

 21.     
class employee 
{ 
var 
var 
= new employee; 
= "Fred"; 
= 5324 
        
        
. 
     ,   
          .   -
,         addslashes(). -
   ,        . 
       
$new_object = 
,        stripslashes(),  
        
     
    ,   ,  -
 . 
   
  ,         
,   get_loaded_extensions()  
 get_loaded_extensions()  ,    -
,     .      
   get_extension_funcs(),     
   . 
   21.1    ,    
 . 
 21.1      ,   
     
"Function sets supported in this install 
$extensions = 
foreach ($extensions as $each_ext) 
{ 
echo 
echo 
$ext_funcs = 
as $func) 
{ 
echo 
} 
echo 

J  4.     
 ,      -
, a      . 
   ,   ,   
  . 
   
,       (-
 )     
echo 
         . 
     
        -
. 
        
(        -
): 
a, j M 
    UNIX,      
date()       . 
   
      ,  -
 
     .  UNIX   -
    Windows   
    
     FTP ( Windows-). 
    ,    :   -
    php.ini.   ,   
     . 
      ,  
  enable_dl   php.ini.   ,   
  .        
.      ,   dl()   -
. 
    
    php.ini        
 .     , ,  
      -
 . 
        ini_get()  
          
21.2. 

 21.    PHP / 
 21.2 iniset.php       php.ini 
= 120) 
echo old timeout is 
= 
echo new timeout is $max_execution_time 
   .     -
    php.ini,      .  
    . 
        -
  120  ( 30  ). 
 ini_get()    ,    
,    .     -
    ,     . 
    
     ,    
 .         -
   Web-  . 
   . (, 
     
     . (    -
,      -  .) , 
   ,       -
  ,    , ,    
HTML-.      . ,  -
      ,    . 
   ,    -
 ,           . 
        php.ini. -
     : 
Colors for Syntax Highlighting mode 
= #DDOOOO 
= #FF8000 
= #007700 
highlight.bg = #FFFFFF 
= #OOOOBB 
= #000000 
    RGB- HTML. 
  
  V     ,  
    MySQL.      -
 ,     MySQL   . 
  22   ,     -
  ,        -
,  ,    . 

22 
23 
24 
25 
26 
27 
28 
29 
30 
 
  
  MySQL 
   MySQL   
  
 
  
  
    
  ,   Web 
    
 Web- 
 
    (PDF) 

 PHP  
MySQL  
  
 
     -
     MySQL.   
     ,   
-    -  -
  100  . 
  Web-   -
 .    "" Web-
      -
     .    Web-  
Web-,  ,  -
 ,   Web.  -
    Web-   
   .    -
       ,   
    . 
     ,  
    Web-. 
   , ,  -
  ,    - . 
     : 
     
   Web- 
     
 
    
      
   
    

  5.      MySQL 
   
  
  ,   : PHP, HTML  CSS 
   
    
   Web- 
,   ,       -
       .  
,         -
. 
,        Web-,  
   . 
-,  Web-    .  
   ,    . 
    .       
   . ,     Web-
  ,      ,  , 
   .       -
    . 
    ,    Web-  -
      .    -
          
      ,   
   .   Web-  -
      . 
  Web-     ,   
      :   ,  
 . 
        
,    Web-,     . 
    Web- 
       Web--
.    ,   .    
,        . -
       ,    -
   .        -
   ,    . 
        .  
 .    Web- -
  ,    ,   , -
    . 
      .   -
 ?     ?  -

 22,  PHP  MySQL      
     ?   ,    
  (use cases). 
     ,     -
.       , 
,     .     
    ,     .  ,  
   (Open Source)    -
. ,      , , -
,     . 
  .  Web-   . 
    ,  , - 
,  ,    ,  
      . 
      .  
 .     . 
,          -
.      . 
  . 
    ,      -
 . 
   
     ,   .  -
        , -
     , ,    . 
     ,     -
  ,      -
.         
          . 
   ,      . 
 ,    ,     -
  ,      .  
    ,       
 .  ,     : 
      -
,    PHP-    -
   .     " " 
sugar).            -
 .     ,    . 
 ,        . 
   ,    . 
 ,      -
   ,   .      
    .      
,    ,    Web  Web-

 4  5.       MySQL 
,  ,    - .   -
    Open Source   ,     
,  ,  .   , -
  ,      ,   
          -
. 
         
   ,     .   
       ,   -
. 
     
    Web-  .   
   .       -
  ,    .   
          -
    . 
   
  ,   -
,         
 ,  ,      .. 
   Web-    -
,       .   -
     ,    -
.     ,      
   .     ,  -
      . 
  
      : 
     .     
           . 
   .    
,        
. 
    ,     -
  ,      
     . ,  -
   $   ,    .  
(  )  , 
   (      -
). 
    .  ,  
     .  ,   -
  :   ,      -
. ,  ,      .  -

 22.  PHP  MySQL     3  
   ,     -
. 
       .   
     (,   
   (, PI). 
         ,   
  , ,  ,   , 
    . 
     , , $WaReZ.  -
  . 
 ,     ,   -
 .       : 
  ,      ,   -
  .      
      -. 
       ,   -
 .      . , -
   PHP-  ,   -
 : (  )  mysql_connect() 
(  MySQL).     .  -
,          -
     .    
 .  -     ,    
  . 
 ,  ,         -
.   ,       -
. 
    ,     
PHP-       . ,   
  MySQL    mysql_,     -
 imap_. ,      (shopping cart)  
   cart. 
  ,          
.      . 
  
      .   
,   .        
  : 
 ,       ( include) -
.        , -
   . 
 .     ,  -
    . 
13 216 

386  5.      MySQL 
 .   .     
     ,     . 
      .     -
      ,     -
 . ,        
: 
//   
//    
//  
  ,         
 . 
   .  -    -
    ,     .   
        : "   
 
          -
.           -
       . ,     , 
            -
  ,   . 
  
        -
  ()   .   -
    .     
. 
   ,   , -
    .      
(  ),    .     -
.   ,        
 .           
 . 
     .    
 : 
 1: 
if (condition) { 
//  
 2: 
if (condition) 
// -  
      . -,    
        . 

 22.  PHP  MySQL     3 7 
 
     .   
   ,        
 .       / ,    
    . ,    
          
       : 
     . 
         -
 . ,    dbfunctions.php  
    ,      -
.       ,   
    . 
       .  
   ,        
  .  ,  ,   -
     ,    -
   (" "). 
          
  ,     .   -
  ,       ,  
       .  ,  -
,       ,    -
 ,       . 
          , 
         
  .         , 
   .  , -     -
   (build manager).     
         .    
   ,     .  -
        . 
    
    ,     -
    Web-.       
   ,         
.      , , -
    .    -
       .  -
 . 
     
  ,       -
 .        -
   .      . 
         . 

         MySQL 
,       ,    
  ,     .    -
          -
. 
  
    ,     -
   .    -
      ,    
       (, , -
). 
 ,         
   .       , -
   .         
        .  ,   -
    ,      -
. 
       . 
          
,         ,   -
      .      
 ,     .   
      .  ,  -
   ,       ,   
   . 
       
   .       
  (   ).     -
     .    ,     
.      ,  
  . 
      .  
,           
. ,          . 
        .  
       .    
       ,     .  
   ,     -
      .      -
 ,   . 
  ,    UNIX / 
 Open Source,  CVS (Concurrent Versions System   -
 ).  CVS       -
          UNIX.  
,      DOS, Windows  Macintosh.   
 /,         
Internet-,   CVS   .     -
   PHP, Apache, Mozilla    ,  
 , . 

 22.  PHP  MySQL     
CVS    Web-  : 
   CVS    ,  
,     Java  Windows,     -
 .        
. 
   CVS.     Microsoft Visual 
Source Safe      Visual Studio. 
   
         .  
         -
 .        
   (IDE  integrated development environment).  -
     IDE    . , 
     ,   -
 ,       Web--
.        (  ,  
     ,    -
). 
     IDE  .  
      : 
 Zend IDE  Windows  UNIX: 
 ,    /,   -
 ,     ,   
    .       
.        -
  Web-. 
 KPHPDevelop   Desktop Environment   Linux: 
 IDE    ,    -
,     . (   -
   CVS.)     
     ,   MySQL, PostgreSQL  Sybase. 
 PHPCoder   Win32: 
     ,   .   -
        -
  ,        -
.  PHPCoder  . 
 PHPEdit   Win32: 

 5.     MySQL 
         , -
   .     -
    . 
 PHPGem: 
       PHPGem -
   ,  ,  ,  
MySQL  PostgreSQL.  PHPGem   PHP-, -
      . 
,      .   , 
     . 
  
        -
 : 
   
  /  
   (   ) 
   (  Web-   -
) 
      ,    ,   
        . 
         -
    ,     -
. ,   HTML-,  -
      Java-. 
      .    
 : 
 phpDoc: 
       MySQL.  , 
  phpDoc       
. 
 PHPDocumentator: 
  ,      
javadoc,     . 
 
    ,   javadoc. 

 22,  PHP  MySQL     3 1 
      ( ) -
   SourceForge: 
 SourceForge,  ,    
UNIX/Linux,        . 
  
     ,  -
   Web-.     -
  .       
 ,          
 .       -
  .       -
          -
 .  ,  -     
. 
  "" ,     .  
     .     
     .   -
     ,    -
 . 
      .    
 ,   ,       
 . 
    ,      
 ,        .   
 ,    ,     
  .      ,  -
    ,   .   ,  
Web-      ,    -
    .      -
,   . 
      ,     
.   -  ,   .  -
,      ,      
 . 
    ,       -
.   ,  ,  ,    -
,      -
. -    , ,     
. 
   ,      
  ,         -
 ,    . 

  5.      MySQL 
    
,      HTML    
Web-      (CSS  cascading style sheets) 
   .      
     .    
  ,      . 
    PHP-  HTML-. 
           
      .    -
        .  -
        .   -
   Web-,       
HTML-,       . 
         : 
        . 
  ,   ,     -
.       TLA Consulting   5. 
  API-       
       -
 .      6. 
   .      
     -
 .       ,  
   - ,     
  PHP-.     -
    . 
    . ,     
 FastTemplate: 
  
 ,       Web,    
 .     ,    -
  Web-       .  
        . 
   
  ,     ,  -
  .      ,   -
    ,   MySQL.    
 : 
     .      
      .   -
     . 

 22.  PHP  MySQL     
     .     
   .   (, , ) -
     .   
          
 .  MySQL       
 EXPLAIN. (      
          
  . 
        PHP-.  
  HTML-   echo  -
   . (      -
   .)      -
  .       
 ,        .  -
         -
  ,       
     . 
         -
 .      . 
          -
,    .       
,  ,     -
.      .   -
,       . -
      ,    
HTML-. 
   Zend 
 Zend Technologies    (  -
 ) ,    4.     ( -
,     )    3.  ,    
 ,     4. 
      Zend Optimizer.  -
          -
  40%  100%.      -
  4.0.2  .     ,   
   Web- Zend  : 
     ,   -
    .     
Zend Cache,    PHP-   . -
 ,         -
.      . 

394  5.      MySQL 
 
          -
,   ,    Web.  -
 -     ,    .  -
 .    ,   
    . 
        . ( -
     ,       -
.) 
-,   ,     -
   .    : 
   
  ,     
   
     
  ,     -
   
    
     ,    , -
   ,    . 
    ,    Web-
,       .   
Web-      ,   Web- 
   .    ,   -
   .       
 .   Web-   -
  .      
.       . 
    Web     
 .      ,  -
  . 
         --
 Web-. ,  ,    -
,         
  .   100   -
      . ,       
   ,       .  
 Web-   ,     
         . 
(        -
     .) 

 22.  PHP  MySQL     
 
      .   
 . 
 Web-    Web-   -
    Web Site Engineering: Beyond Web Page Design   
(Thomas A. Powell).          -
. 
       Web- CVS  : 
org 
       (    
  ,    Open Source with CVS -
   Franz  CVS Pocket Reference (Gregor 
N. 
PHP-, IDE        
SourceForge: 
       Web-  Zend.   
   .     -
 . 
    ,     
 ,  ,    
,     Web-.  Web- Extreme 
Programming: 
  
  23     ,  
  ,        -
. 

23 
 
    PHP-.   -
       
 ,       
 .     -
    .  -
 ,     
      -
 ,   . 
    : 
    
   
    
   
    
   
    
   
   
  
      -
   : 
   
   
   
     ,  
    , -
,    . 

 23.   / 
  
   ,  ,  -
   .      -
, , ,    ,  .  -
    , ,     
.         -
 ,   ,   ,     
 ,     Java. 
     ,  ,   . 
     . 
     ,     -
    .      
    .     -
. 
 ,   ,      
,    ,     -
     .    ,  -
 ,         -
   . 
         -
.     ,       
   . 
     : 
Parse error: parse in 
on line 2 
    : 
<? 
$date = 
?> 
      date() ,    
  ,    . 
  ,  ,   . 
  ,      ,   
  ,    : 
<? 
$date = 
?> 
    : 
Parse error: parse error in 
on line 4 
,       ,   
    .      , 
      ,    
 . 

    5.       MySQL 
     : 
if (true) 
echo "error 
     ,     
   .     ,  -
     .      1001 (parse 
error on 1001) ,   1000 ,    -
. 
  ,      -
.   ,    . 
   
       . -
         . -
       .  
         . 
  
include 
 .     . 
      .  , 
  filename.php  ,     
   ,       : 
Fatal error: Failed opening required ' 
in 
on line 1 
   ,        -
      .   -
  . 
      .  ,  
           
. 
$i = 
$j = 
$k = 
     : 
Warning: Division by zero in 
on line 3 
    .      
     ,       
    . 
       ,   
    . 

 23.  
      : 
    
      
   MySQL     
     
     
    . 
   
    .     
 .      , 
    ? 
 ,    ,     -
 ,      .     -
 ,   
      : 
Fatal error: Call to undefined function: 
in on line 1 
  ,    ,     
,   . 
           ,  
   .     : 
  : 
Warning: Wrong parameter count for in 
on line 1 
 PHP    ,     -
,       . 
     : 
<? 
== 4) 
{ 
        , 
  $var   4.      -
. 
    ,      
    ,       
.       ,   
        .   
       .    -
      . 

  5.      MySQL 
     
       ,   
    .      , -
     .      
 ,          
. 
      ,   fopen(), -
  ,   .   fopen()  
  false. 
        
     . 
  MySQL     
    MySQL       
 .       
: 
 MySQL Connection Failed: connect to MySQL server on 
(111) 
 MySQL Connection Failed: connect to local MySQL server through 
socket (111) 
 MySQL Connection Failed: Unknown MySQL Server Host (2) 
 MySQL Connection Failed: Access denied user: 
(Using password: YES) 
 ,       
 false.  ,       -
  . 
          
,       .  -
         MySQL -
     ,    
. 
    PHP-,    MySQL, 
   false   .     
 
    ,      -
         
   MySQL   , -
  , a   0. 
,           
.    : 
$result = * 
echo 
echo 
echo 
   : 
1146 
Table not exist 

 23.  
 ,        -
  MySQL (     
  ,      -
   . 
    ,       -
 .        ,  
 MySQL       .   
    ,       -
   ,   .     
,  ,       Web-
     . 
         
.           -
,       ,     
. 
        ,   -
       -  . 
SQL-,     SQL    -
  ,   ,   . , 
 : 
select 
 ,      . -
            
  SQL-,      -
  ,   ,    .   
,    ,     -
,     . ,    -
   ,       exists    
 column name,  : 
select exists where = in 
 ,     . 
    ,     
  ,       . 
    
       ,     
 ,    .      
    ,   ,  ,  
      .     
    ,  -
  . 
  ,     , -
 ,      . 
  : 
$sp = ( 5000 

  5.      MySQL 
           
 5000  
     : 
$sp = ( "localhost", 5000, &$errorno, &$errorstr 
echo "ERROR: $errorno: 
         -
 ,    .      : 
ERROR: Connection 
        -
,    ()       
 .        
 ,        . 
     ,    -
 .     ,     , 
   . 
        -
     ,    
.  ,       -
   ,   . 
  ,       . 
, MySQL    200     -
.       ,   -
 ,     ,    . 
    
       . 
      ,      -
   . 
         
 ,       AddSlashes() (-
 ).   ,     , -
, O'Grady,     . 
         
   . 
  
         -
.    ,       -
,      . 
     ,    -
: 
for ( $i = 0; $i < 10; $i++ 
{ 
echo "doing 

 23.  
    .    . -
        -
.     ,      -
 . 
 ,   "doing something"     for 10 
.          ,    
   .  for   10  -
,        echo. 
    ,     ,  -
    .      
,        .   -
  ,   .  ,    
  . 
      ,   
         -
.      .   ,  
    .       
 . 
,     ,  ,  
   .   ,         
  .      . 
 ,  ,     
  .   22   -
         -
,          
.     ,  -
,      ,    -
    . 
,       Order Quantity (-
 ).   ,      -
 ?    " ",    -
         ? 
,       .    
   ,   ?     ? 
       (,   
JavaScript),    . 
    ,   ,  -
      URL-,   -
? 
     .   -
   .   -,   
       , -,  
       ,    
   . 

  5.      MySQL 
    
       ,  
   .  23.1   ,  
  .     ,  
. 
 23.1 dump_variables.php          
      
<? 
//       
//    
echo BEGIN VARIABLE 
echo BEGIN GET 
echo 
echo BEGIN POST VARS 
echo 
echo BEGIN SESSION VARS 
echo 
echo BEGIN COOKIE VARS 
echo 
echo END VARIABLE 
//     
//   ,   
//       
function 
{ 
{ 
$size = 
$string = 
{ 
= 0 
$string .= 
//         
as $var => 
{ 
.= = 
< 
{ 
.= 
} 
} 
$string .= 
} 
return 
else 
//     ,   
return 

 23.  
      ,  . 
   cookie- 
  ,      . 
     HTML-. 
     : 
<!--{ = var2 = var3 } 
    HTML- ,    
  ,        -
  .      . 
     .     
  20.4,       20,  -
   : 
BEGIN VARIABLE 
BEGIN VARS --> 
BEGIN POST VARS --> 
<!-- { userid = testuser, password = testl23 } --> 
BEGIN SESSION VARS 
<!--{ = testuser 
BEGIN COOKIE VARS 
<!-- { PHPSESSID = } > 
END VARIABLE DUMP 
 ,     -
     userid  password.  ,  -
  ,      - 
    20,   cookie-   
    .   -
  PHPSESSID,       -
 . 
    
      .  -
  ,  .     -
   ,    . 
       , 
  . 23.1. 
    ,    -
. ,       -
    .     
        . 
    (   ) -
  : 
& ~E_NOTICE 
     ,   -
    . (&)   
 AND,   (~)    NOT.    
:  ALL AND NOT E NOTICE. 

406  5.      MySQL 
 23.1      
   
1 E_ERROR       
2 E_WARNING       
4 E_PARSE      
8 E_NOTICE   ,    
   
16 E_CORE_ERROR       
32 E_CORE_WARNING        
  
64 E_COMPILE_ERROR     
E_COMPILE_WARN!NG      
256 E_USER_ERROR      
512 E_USER_WARNING     
 
1024 E_USER_NOTICE     
 
2048 E_ALL       
      .   
,       OR (|): 
| | | E_NOTICE | | | 
| | | | 
        -
   ,     ( 
E_ERROR | | E_PARSE | E_CORE_ERROR | 
| | 
| | WARNING | E NOTICE 
     
         php.ini  
    . 
      ,  -
      php.ini: 
= & ~E_NOTICE 
= On 
log_errors = Off 
= Off 
   : 
   ,   
       HTML    

 23.  407 
      
   ,     
      ,    
      .   
    ,      -
 ,          
   . 
          -
      -
  ,         
       -
       .   
        .  
        . 
       
    ,       
 .       -
,   ,     . 
   ,     : 
error message in 
on 
   .        
,     . 
 HTML-  ,   .  
        .  , 
     ,  Netscape  -
   .   ,  HTML-,  ,   -
  , : 
<trxtd> 
error message in 
on line 
  Netscape    . 
          
     .    -
          
         -
   ,      php.ini.  -
   .     -
 : 
//     
$old_level = 
// ,   
//       

   5.      MySQL 
       ,   -
 ,   ,   -
. 
    ,      -
 . 
   
      -
       ,     . 
     ,  , ,  
.     : 
 E_USER_NOTICE.    ,     
E_USER_NOTICE. 
     
computer will in 15 
( ,         4.0.1.) 
   
      ,   -
  C++  Java.       
   .      , 
 4.0.1  ,      -
  ,    ,   -
   . 
    ,  
    ,   .  
   ,     
  . 
           -
.      ,     
 .        
.     . 
     
       
   .    : 
string error msg) 
    . 
   : 
      
      
          
      exit 

 23.  409 
 23.2  ,     , -
        -
 . 
 23.2 handle.php       
     
//    
function myErrorHandler ($errno, $errstr) 
echo bgcolor = ' 
<PXB>ERROR:</B> $errstr 
<P>Please try again, or contact us and tell us that 
the error occurred in line of file FILE 
if ($errno == |$errno == E_ERROR) 
echo error was program 
echo 
 ,   .. 
exit; 
echo 
//    
  
function 
computer is 
include 
computer will self destruct in 15 seconds", 
E USER 
    . 23.1. 
 23.1 
  
 , 
   
 . 
in foe S 
ERROR: f : 
or us feat 
tty or us E fife 
 
ay of 
ERROR: If 
try or us and F. 

  5.      MySQL 
       . 
    ,      -
.         , 
    ,     . 
  ,     .   
  ?     -
?       ? 
 ,        
   .   ,      
   ,  -  -
 .   ,        
 ,     ,   -
     . 
  
   3   .    ,  
           
 ,   . 
     4,      
  Zend. 
  -    3    , 
    ,     -
      php.ini: 
debugger.port  
   ,    ,  
 ,  . 
  
  24      .    -
           
. 

  
 
 
    -
  Web-.     -
       
 .   - 
. 
      
 Web   (bookmarks)    
,    , -
      .   -
     -
    Web-,   
      . 
 ,         
  ,  ,   
.       -
 ,    ,   -
  . 
    -
: 
    
   
    
   
      -
    
 
     -
,  PHPBookmark   (  
 ) ,  

  5.      MySQL 
          
  ,       
,     . 
        . 
-,      -
.  ,     . 
-,        
.        . 
-,       -
     . 
  
,     ,     
   .        -
 ,  . 
   
  ,     -
.        , 
          MySQL    
. 
       , -
    ,     : 
       . -
         . 
        . 
         , 
     . 
         -
   .      ,    -
 ,       , 
    . 
     ,     -
,     ,    . 
          -
. 
     .    -
     .   
        , -
  .      -
    .     -
     ,     
      . 
       . -
          -
   . 

- 24.    
  
          
 MySQL.    : 
       . 
     .  ,   
  URL-. 
    . 
  
       . 
         -
 .       ,  
  "  ".     , 
   ,       ,    -
   .    , -
  ,     ,  -
     . 
        . 
  
     -,   . 
 
 
     
 
 24.1         

414  5.       MySQL 
      .    -
  ,    .  ,    
 : 
  . 
    . 
    . 
    . 
    .  HTML-     
.         
. (     API     .) 
 ,       . 
    ;     
    chapter24  CD-ROM.    -
  . 24.1. 
 24,1   PHPBookmark 
  
register_form.php 
php 
php 
php 
bookmark.gif 
 
SQL-     PHPBookmark 
        
     
     
,  ,   
    
       
  
     
       
      
  ,     
  
,     
      
     
     
      
      
   
    ,    
 
,     HTML- 
  PHPBookmark 

 24,    
     MySQL,     -
     . 
         .   -
 ,    ,   -
 ,    .    
         , -
     . 
 
       ,    
magic quotes.    ,       MySQL -
         
stripslashesl).        . 
   
   PHPBookmark    . -
   ,      .  , 
  URL- .      -
,          . -
         ,   
 . 24.2. 
user 
passwd 
7cbf26201e73c29b 
1fef10690eeb2e59 
email 
luke@tangledweb.com.au 
bookmark 
username 
laura 
laura 
http://slashdot.org 
http://php.net 
 24.2      PHPBookmark. 
     (  ), -
    . 
        -
         
. 
 24.1  SQL-     ,   -
      Web.        
,         ! 
 24.1 bookmark.sql  SQL-      
database 
use bookmarks 
create table user ( 
username primary 
passwd not 
email not null 

416  5.       MySQL 
create table bookmark ( 
username not null, 
not null, 
index 
index 
grant select, insert, update, delete 
on 
to identified by 
    ,      -
   (root)  MySQL.    
    : 
-u root -p < 
    . 
,    ,     . 
   
   login.php,   -
    .       24.2. 
 24.2 login.php     PHPBookmark_ 
<? 
    ,   ,  ,  -
  API-,      .  
   .  ,    
 ( ),      HTML--
,      . 
    . 24.3. 
     bookmark fns.php,    24.3. 
 24.3        
PHP Bookmark 
<? 
//        
//       

 24.    
 24.3 
  
 
  
 HTML  
 
& Stop 
PHPbookmark 
Store with) 
See use! 
links 
] 
,          -
 ,      .   
 ,      .    
    ,      -
 .   ,       
     .     
  ,     include. 
 ,      , -
       ,  -
   include()  ,      
 . 
        -
   HTML-.     , 
     login.php  
     . 
      ,       -
 .      24.4. 
 24.4  do_html_header()   -   
  ,      
 
function 
//  
<head> 
<titleX?=$title?X/title> 
<style> 
body { font-family: Arial, Helvetica, sans-serif; font-size: 13px } 
td { font-family: Arial, Helvetica, sans-serif; font-size: 
hr { color: 
a { color: #000000 } 
14 216 

   5.      MySQL 
</style> 
logo" 
align=left valign=bottom height = 55 = 57> 
<hr> 
<? 
if 
 ,         
 .  ,     . 
 display_site_info()    ; 
    ,   . 24.3;  
     HTML. 
(    HTML-     
   22.   ,    API.  
     ,   .) 
 . 24.3 ,        -
 ,   ,    ,  -
  .        -
   . 
  
      : -
 ,     ,     -
.    . 
 
  ,      
       . 
        ("Not a 
    ,   
     24.5. 
 24.5       
   
           -
   output     . 24.4. 
          
     -
     Register,   
   24.6. 

 24.    
 24.4 
  
 , 
  
   . 
   
 
  
 . 
fedit Tools 
PHPbookmark 
Registration 
 " 
me 
 
Password 
Confirm pis 
 24.6       
        
//     
require 
// ,     
//    ,    
//   
//   
if 
echo "You have not filled the form out correctly - please go back" 
. and try 
do ooter () 
//    
if 
< 
echo "That is not a valid email 
. and try 
do ooter 
Please go back 
//    
if != $passwd2) 
echo "The passwords you entered do not match - please go 
and try 
ooter () 
exit; 

  5.       MySQL 
  
//    ,  
//     
if || ($passwd) >16) 
echo "Your password must between 6 and 16 
go back and try 
} 
//   
$reg_result = 
if ($reg_result == "true") 
{ 
//   
$valid_user = 
//     
echo "Your registration" was Go to the members page 
start setting up your 
"Go to members 
} 
else 
{ 
//     
//     
echo 
} 
//   
  -   . 
        . (  
   ,  ,    
  20.) 
    ,  . -
   : 
 ,   .      
fiUed_out(): 
if 
    .     
   . 
      : 
if 
         
data_valid_fns.php. 

 24.    
     ,  : 
if != $passwd2) 
    : 
if < 6 || strlen > 16) 
          , 
    ,   16 ,     
 . 
      filled_out()  
, ,   24.7  24.8. 
 24.7  filled_out()  data_valid_fns.php    
,    _ 
function 
{ 
// ,    
foreach as $key => $value) 
{ 
if || == 
return 
return 
 24.8  valid_email()  data_valid_fns.php    
     
function 
{ 
//     
if 
return 
else 
return 
 filled_out()      
   ,    true,  -
   false. 
    ,   -
 4     .   ,  -
 true,     false. 
        
.     24.6,    : 
$reg_result = 
if ($reg_result == "true") 
{ 
//    
$valid_user = 

422  5.      MySQL 
    
echo "Your registration was successful. Go to the page 
start setting up your 
"Go to members 
   register()   ,   
  ,    .      
          
   .     . 
24.5. 
a Internet 
 24.5 
  
  
   
. 
" View fclefp  . 
' Home 
PHPbookmark 
successful 
Your Go to page to setting 
up your 
Go 
 register()        
24.9. 
 24.9  register()  user_auth_fns.php  
         
function $password) 
//       
// true     
//     
$conn = 
if (!$conn) 
return "Could not connect to database server - please try 
//     
$result = * from user where 
if (!$result) 
return "Could not execute 
if 
return "That is taken - go back and choose another 
//       
$result = into user values 
, 

 24.    
if 
"Could not register you in database - please try again 
return 
           -
   .        
     ,    false.  -
        true. 
,          
        
       .  ,  -
        . -
    24.10. 
 24.10  db_connect()  db_fns.php -  
    MySQL _ 
function 
{ 
= 
if (!$result) 
return 
if 
return 
         -
 ,    .      -
. 
   
         . . 24.3) 
  ,         
.  ,     .  -
    .      
 24.11 member.php       _ 
//       
if .& $passwd) 
//     
< 
if 
< 
//     , 
//  
$valid_user = 

424  5.      MySQL 
else 
//     
echo "You could not be logged in. 
You must be logged in to view this 
//   
if ($url_array = 
//   
           20. 
-,  ,      -
 .  ,       .  -
     : 
if && $passwd) 
//        
{ 
if 
{ 
//    , 
//   
= 
} 
      login().     
  . 
      ,     
 .         
   ,    -
: 
//  ,   
if ($url_array = 
//   
ooter () 
     .  ,    
       
get_user_urls()   url_fns.php    

 24.    
check_valid_user() ,   
   -
 .    
,    
,       . 
  -
    ,  
   
.   check_valid_user() 
  ,   
       
   . 
  -
    -
  
   
  . 24.6. 
    
  -
    24.12. 
 24.12  login() 
 user_auth_fns.php  
     
  
Hume 
"  ' 
PHPbookmark 
Home 
Logged in as 
  
 
Home | Add I 
Recommend URLs to me 
| 
,! Si 
 24.6  
,     , 
    ,  
  . 
function $password) 
//          
//     
//     
//    
$conn = 
if 
return 
//    
= * user 
where 
and passwd = 
if (!$result) 
return 
if 
return 
else 
return 0; 
          -
     .    ,  
 true,   ,        
,  
 check_valid_user()       , 
 ,      .  -
,     .      24.13. 

   5.       MySQL 
 24.13   user_auth_fns.php  
     _ 
//     , 
//  ,   
{ 
global 
{ 
echo "Logged in as 
echo 
else 
//      
echo "You are not logged 
exit; 
     ,   ,    
,    ,      -
 . 
   
   . 24.6,    "Logout".     
    logout.php.      
 24.14       _ 
<? 
//   
$old_user =  ,  -    
$result_unreg = 
$result_dest = 
//  HTML- 
if 
{ 
if ($result_unreg $result_dest) 
{ 
//         
echo "Logged 
, 
} 
else 
{ 
//         
echo "Could not log you 

 24.   
else 
//    
//   
//    
echo "You were not logged and 
so have not been logged 
} 
     -
.    , -
   20. 
  
     
"Change Password",  , -
  . 24.7.  24.7  
    , 
 
    
    . 
     . 
       -
 24.15. 
 24.15        
fcjeip 
Beck .' . Home 
p 
PHPbookmark 
Change password 
Logged in as laura 
Old j 
Add i  Chan 
Recommend to me 
) 
if 
{ 
echo "You have not filled out the form completely. 
Please try 
() 
exit 
else 
if 
echo "Passwords entered were not the Not 
else if || 
echo "New password must be between 6 and 16 
else 
//  
echo "Password 
else 
echo "Password could not be 

   5.      MySQL 
  ,      ( 
       -
       .   , -
  
if 
echo "Password 
else 
echo "Password could not 
         
24.16. 
 24.16  change_password()  user_auth_fns.php   
      
//   
//   true  false 
{ 
//     
//      true, 
//     false 
if 
{ 
if = 
return false; 
$result = "update user 
set passwd = 
where = 
if 
return false; //    
else 
return //   
} 
else 
return false; //    
          -
     ,     
     . 
   
       , 
    .  ,   -
, login.php,   "Forgot your   -
 .       
    (. . 24.8). 
   .      , -
    .      
   .   -
   

 24,    
 24.8 
 
 ,  
  
  
   
   
 . 
3 
PHPbookmark 
Reset password 
password 
 24.17 forgot_passwd.php     
    ,       
  
<? 
if 
< 
if 
echo "Your new password has been sent to your email 
else 
"Your password could not be mailed to 
Try pressing 
} 
else 
echo "Your password could not be reset - please try again 
     :  
   . 
        -
.      24.18. 
 24.18  reset_password()  user_auth_fns.php   
         
   
function 
//     
//    false    
//      6  13 
= 

        MySQL 
   0  999 
//   
* 
= 
. 
//       false 
if = ) 
return 
$result = ( "update user 
set passwd = 
where = 
if (!$result) 
return false; //   
else 
return //   
    ,       
         0 999. 
     user_auth_fns.php.  
   
 24.19  get_random_word()  user_auth_fns.php   
   ,     
function $max_length) 
//      
//      
//    
$word = 
= //  ispell 
$fp = "r") 
$size = 
//       
srand * 
$rand_location = 
//        
while $min_length 
if 
//    ,   
$word = fgets($fp, //   ,   
//    
$word = fgets($fp, //   
 \ 
  
return 
} 
    .   UNIX   -
  ispell  ,     -
    .     
     ,    , -
  ispell   : 

 24.    1 
       ( ..   ).   
  , ,     ,  
    .      -
   ,      . 
     ,     -
  0    ,    .   -
,  ,    ,    -
          fgets(). 
     . -,     
   ,     : 
if 
//    ,    
-,     .   -
 ,   .        
  . 
         
,           -
.         -
   . 
     24.20. 
 24.20  notify_password()    
       
function $password) 
//       
{ 
if ($conn = ) 
return 
$result = email from user 
where 
if (!$result) 
return false; //   
else if 
return false; //     
else 
{ 
= 0, 
= "From: 
$mesg = "Your PHPBookmark password has been changed to $password 
change it next time you log in. 
if "PHPBookmark login 
return 
else 
return false; 
           
       PHP-   
 . 
     , -
       ,    , 

432  5.      MySQL 
PHPbookmark 
Add Bookmarks 
Logged in as 
Add 
    .  -
    
   ,   
 .     -
  0   (   
""),  1  1 (   
      
 45000 .   
      
 ,      
,  ,    
22500000.    -
    ,  
     
    -
  . 
   
 
     
,    . 
 
       Add BM   . 
   ,   . 24.9. 
        .    
  .      
   24.21. 
| MA BM | | 
URLs to me | 
 24.9  
 ,    
     
 . 
 24.21 add_bms.php 
  
       
session_start () 
if 
{ 
echo "You not filled out the form completely. 
Please try 
exit 
} 
else 
{ 
//   URL- 
if 
$new_url = 
// URL- 
if 
//   

 24.    43 3 
if 
echo "Bookmark 
else 
echo "Could not add 
} 
else 
echo "Not a valid 
// ,   
if = 
      ,    
   . 
        filled_out() -
,    . 
    URL-.     
,      http://.  ,  -
   .    ,    -
 .     17,    
,       , 
,  URL- ,    add_bm()   
   . 
 ,       -
,       Internet.     -
 HTTP-  -,   . 
   ,   ,    
  add_bm()    24.22. 
 24.22  add_bm()        
  _ 
function 
{ 
//       
echo "Attempting to add 
global 
if = 
return 
// ,    
$result = * from bookmark 
where 
and 
if ($result &. 
return 
//   
if "insert into bookmark values 
return false; 
return true 

 5.      MySQL 
   .  ,      -
   . ( ,     , 
  ,    .)   
,     . 
   add_bm.php.       
    get_user_urls()    -
 . 
  
  member.php     get_user_urls() 
  , ,     
   .     
a display_user_urls()    
 get_user_urls()    24.23. 
 24.23  get_user_urls()     
     _ 
function 
{ 
//      URL- 
if = () 
return 
$result = "select 
from bookmark 
where = 
if (!$result) 
return false; 
//   
$url_array = array 
for = 1; $row ($result) 
< 
= 
} 
return 
   .       -
        .    
URL-   false,      . 
        
display_user_urls().     HTML-,  
 URL-    .    -
.     . 24.6.   URL-  . 
   URL-  ,    -
  . 
  
           
 Delete BM,  ,  URL-.   -
      
echo type=checkbox 

 24.    
     , ,    -
,         -
 . 
 Delete BM      24.12. 
 2424        _ 
<? 
() 
if 
{ 
have not chosen any bookmarks to delete. 
try 
} 
{ 
if >0) 
{ 
me as $url) 
< 
if user, 
cho "Deleted 
else 
echo "Could not delete 
} 
> 
cho "No bookmarks for deletion"; 
//  
if ($url array 
() 
      .  -
,       ,   -
   : 
me as $url) 
{ 
if 
echo 
echo "Could not delete 
 ,        
.     24.25. 

436  5.    MySQL 
 24.25  delete_bm()      
    
function delete 
f 
//   URL-  
if = 
return 
//   
if ( "delete from bookmark 
where and 
return 
return 
    .       
   . ,    -
  "   ".     
  . 
      . 
          -
        
  
,     , 
      
  " ".  ,   -
 ,           
. ,   -
    
  . 
    
  SQL-   -
.    -
     
,     
    . 
,   , MySQL 
   . 
     
        
.     -
    -
     -
 . 
  .  
 , ,   
  , 
     
    . 
Deleting bookmarks 
Logged in 
http:Mheaqe.com.au. 
com 
 
 
 
| Add | I Change 
URLs me | Logout 
 24.10   
  ,   , 
  . 

 24.    43 / 
    : 
select distinct (2 
bookmark bookmark 2 
where 
and != 
and = 
          
     ,    . ,  -
        2.     -
     .     -
   .     
  (URL-),     
 =        
  (bl.username 
    ,     
  .   ,   
         : 
select 
bookmark 
where username in 
and not in $user_urls 
group 
having 
 $sim_users      . 
         
     ,     . -
,        -
  " " .    URL-, -
     . 
       ,  
      URL-, 
   .     
          Web-
. 
        24.26  
24.27.    (.  24.26).   
   url_fns.php (.  24.27). 
 24.26 recommend.php    ,   
  
<? 
$urls = 

438  5.       MySQL 
 24.27  recommend_urls()      
  
function $popularity = 1) 
{ 
//   
//   URL-, 
//     
//      
//   
if = 
return 
//     
//      
if = 
select 
bookmark bookmark 2 
where 
and != 
and = 
return false; 
if 
return 
//      
// URL-     IN 
Srow = 
$sim_users = 
while ($row = 
{ 
.= 
} 
.= 
//   URL-  
//   ,    
if = 
select 
from bookmark 
where 
return 
//   URL- 
//     IN 
$row = 
$user_urls = 
while ($row = 
{ 
$user_urls , 
} 
$user_urls 
      
//      
//   URL-  
//    
//  $popularity =    
// ,      

 24.    
//    URL- 
if = 
select 
bookmark 
where in 
and not in 
group by 
having 
return 
if 
= () 
//   
= $count++) 
{ 
= 
} 
   recommend.php   . 
 24.11 
,  
  
pets.com.   
   
   
slashdot.org. 
Home Search 
PHPbookmark 
Recommending URLs 
Logged as 
com 
| Add | : 
URLs me I 
,\ password 

 5.      MySQL 
    
      
    : 
     
    "Add this to my bookmarks" (   
) 
 ,     URL-   
    
      
   ""     
         
 
      
!    ! 
  
     ,   
   ,     
     . 

25 
 
 
 
      -
  (shopping cart).   
     -
   2.     
     -
       
. 
   (  
 ,  , shopping basket) 
    -
 .     
       -
 ( ).    
    -
   ,  , -
  . 
      
 : 
   ,    
   
       -
 
  ,   
,     -
 
  ,    
    
   

  5.       MySQL 
 
,        -
 .       .    -
 : 
         -
.       , 
  . 
          -
  .    . 
       ,   
    . 
      Book-O-Rama. -
        
    . 
  
      . 
   
  Book-O-Rama    .    -
     .      
 ,    . 
 ,        -
    ,    .. 
  ,       MySQL  , 
       - . 
  
       . 
          ,    
   . 
        -
      ,    -
   .  ,     -
    ,  ,   
      . 
          
    .    -
    ,        
  . 
 ,          
  ,        
 . 

 25.   
        ,  
.      .   
  .      .   
 ,        
. 
        
.        
,  , .        
,     .    , 
     . 
           -
        .     
         ,  -
 ,      .   
     . 
      (,   
),      ( , 
      ),     -
        . -
       ,    -
 . 
  
  ,    ,  
 ,          
 . 
         -
 (,   ).  ,    
   ,   .    
 ,   ,     -
,      .  ,  , 
      ,     
 . 
          -
 .          -
. 
  
 . 
    :   -
.        --
       .    . 25.1 . 25.2. 

444  5.      MySQL 
  
 
  
 
 
 
  
 
   
  
 
 
 
. 25.1       -
       ,       . 
 
 
 
 
 
 
  
 
-
 
 
 
 
 
 
  
 
 
 25.2  Book-O-Rama      
,      . 
 . 25.1        -
 .     ,     -
  .       ,    
   . 
        . 
        . 

 25.    
 . 25.2   .    ,   
   .       -
      . 
          -
        . 
 -       -
,            
  ,      .  , -
      ,  -
   . 
       : 
 . 
      (   , 
  .) 
 . 
    ,     .   
  API- ,    -
 .    ,    HTML-
,   .       
 ,   ,     . 
 ,        
  (Shopping Cart) ,     -
   ,     2. 
       CD-ROM.  -
    . 25.1. 
 25.1   Shopping 
  
   .  
  . 
    
. 
     
. 
    
 .  , 
   
  . 
     
 .  
  . 
      
 . 
      
    . 
     
   . 

   5.      MySQL 
 
 
 
 
php  
 
php 
php 
php 
book_sc.sql 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    
. 
  . 
  
  . 
  . 
,   
     
. 
     
. 
,   
    . 
     . 
,   
 . 
    . 
,   
   . 
    
 . 
    . 
    . 
  . 
 ,  
 . 
     
  . 
     
 . 
   HTML-
. 
   
  . 
     
  book_sc. 
   
SQL-    
SQL-      
 book sc. 

 25.    44 / 
    . 
     .     
 ,     (   
)            -
,    .    ,  -
        . 
     ,    magic 
quotes.    ,     -
    MySQL ,        -
      . 
 magic quotes        -
   .htaccess: 
php_value on ( PHP 4) 
 
on ( PHP 3) 
  
  ,       2, 
  . 
SQL-    book_sc    25.1. 
 25.1  SQL-   book_sc 
create database 
use 
create table customers 
( 
customerid int unsigned not null auto_increment primary key, 
name not null, 
address not null, 
city not 
state 
zip 
country not null 
) 
create table orders 
( 
orderid int unsigned not null auto_increment primary key, 
customerid int unsigned not null, 
amount 
date date not null, 
order_status 
not null, 
ship_address not null, 
ship_city not 
ship_state 
ship_zip 
ship_country not null 
) 

        MySQL 
create table 
( 
isbn (13) not null primary key, 
author 
title 
catid int unsigned, 
price not 
description 
create table categories 
( 
catid int unsigned not null key, 
not null 
create table order_items 
( 
orderid int unsigned not null, 
isbn not null, 
not null, 
quantity tinyint unsigned not null, 
primary key (orderid, isbn) 
create table admin 
( 
not null primary key, 
password not null 
grant select, insert, update, delete 
on * 
to book_sc@localhost identified by 
   ,    -
 ,        -
 . 
  ,     : 
          ,  -
   . 
    .      -
   ,    . 
   ,       . 
      . 
   order_items   ( ),   -
   .      , 
   . 
   admin       -
. 
           -
.        ,  -
  . 
     ,   MySQL   -
 book_sc.sql,     (root): 

 25.    
root -p < 
(    .) 
     book_sc (  
   password). 
 ,        -
     ,      MySQL. 
  
    ,   :  -
,       . 
        -
   . 25.3. 
 ,         -
  (   )      . 
     ,      
 . 
       ,   
,   show_cat.php.    , -
 Internet,   . 25.4. 
   Internet    .   -
     ,      
 (. . 25.5). 
    View Cart ( )   Add to 
Cart (  ),   .     , 
     . 
    . 
 25.3 
 
   
 , 
  
. 
' 
Back   
to 
Please a 
216 

4  5.       MySQL 
 25.4 
  
 
 
 
. 
Step 
' ....... .............. 
PHP bv and Thomson 
Sams PHP4 in Mall 
 25.5. 
   
 
 
,  
 . 
Total 
Total = 
PHP and MySQL Web 
I 
Luke Welling Laura 
ISBN: 
Our Price: 99 
PHP MySQL teaches to dynamic,  
will following 
and working through 

 25.    
  
 , index.php,       (.  
25.2). 
 25.2 index.php      _ 
<? 
include 
//  
to 
echo choose a 
//     
$cat_array = 
//     
//       
//   , 
//     
{ 
"Admin 
} 
do html footer () 
        
    . 
    ,     
  .     
. 
     HTML-,   
 do_html_footer() (    output_fns.php). 
 ,   ,       -
 .        .  
    ,   . 
     : 
//      
$cat_array = 
//      
  , ,  -
 book_fns.php  output_fns.php.  get_categories()   
 ,       -
    25.3. 

  5.      MySQL 
 25.3  get_categories()      
    _ 
function 
{ 
//      
$ = 
= catid, 
$result = 
if 
return 
= 
if =0) 
return false; 
$result = 
return 
          -
   .      
  (.  25.4).   -
   MySQL       , 
      . 
 25.4  db_result_to_array()    
  MySQL    _ 
function 
{ 
$res_array = 
for $row = 
= 
return 
           
      -
     ,    .  -
    25.5. 
 25.5  display_categories()   outputjns.php -
        _ 
function 
{ 
if 
{ 
echo "No categories currently 
} 
echo 
foreach ($cat_array as $row) 
{ 
$url = 
$title = 
echo 

 25.    
} 
echo 
echo 
       .   -
   , show.cat.php,       , 
  (catid). (  ,  MySQL  
   .) 
  ,      
. 
    
        
.       25.6. 
 25.6       
<? 
include 
//     
= 
//       
$book_array = 
//      
//        
{ 
"continue", "Continue 
display "Admin 
"Edit 
} 
else 
"Continue 
() 
         -
     ,     . 
        
session_start(),       
     : 
$name = 
        .   -
   25.7. 

  5.      MySQL 
 25.7   book_fns.php   
     
function get_category 
{ 
//      
= 
= 
from categories 
where = 
$result = 
if (!$result) 
return 
= 
if =0) 
return 
$result = ($result, 0, ,-
return 
      HTML-   
      ,    : 
$book_array = 
 get_books()  display_books()     
 display_categories(),     . -
    ,      ,   
 . 
 display_books()        
  show_book.php. -,    -
   .      ISBN  . 
        
   ,     .   -
  ,   . 
   
 ISBN   ,   -
      .      25.8. 
 25.8      
   _ 
' 
include 
//      
//    
$book = 
//  URL-   "continue" 
$target = 
{ 
$target = 

 25.    
//      
//    
) 
{ 
display "Edit 
"Admin 
"continue", 
else 
{ 
"Add To My Shopping 
"Continue 
} 
do () 
         . 
  ,     : 
= 
      .      HTML 
  : 
,       
 ,       , -
  . 
     .  -
   "Continue Shopping" ( ), -
   ,   Add to Cart     -
 .        ,  
  . 
     .     -
 . 
   
         
 ,    ISBN  ,    -
. ,        , -
   : 
0672317842 => 1 
    ,     .  
         
     . 
 ,        -
    Total Items ( )  Total Price ( -
)  ,  

  5.     MySQL 
  
        
 ,       View Cart  Add 
to Cart.     ,  -
 .       ISBN,  
     . 
      . 25.6. 
      View Cart  ,   . 
 ,        . 
 . 25.7  ,      .   
       Add to Cart  , -
   ,    (    
 ).      URL-,  
,        .   new 
   0672317842   ISBN ,      
. 
,  ' ' 
  
 25.6 
 
  
,  
  
" 
* 
Your 
no 
 25.7 
  
 new 
   
 . 
shopping 
Matt 
Web and 

 25.    
     .   Save Changes (-
 )  Go To Checkout ( ).     -
      .    -
      Quantity     Save 
Changes.  ,    ,     -
     . 
   ,     .  
    . 
       25.9. 
 25.9       
<? 
include 
//    
if 
{ 
  
if 
{ 
$cart = array () 
= 0; 
= "0.00"; 
} 
else 
$cart[$new] = 
= 
$items = 
} 
{ 
foreach ($cart as $isbn => $qty) 
else 
= 
} 
= 
$items = 
} 
shopping 
else 
{ 
echo no items in your cart" 
echo 
} 
$target = 

 5.      MySQL 
     
//     
{ 
$details = 
$target = "show 
"Continue 
= 
$path = 
"Go To 
ooter 
     :   , -
      .      
 . 
 
      ,    
   .        View Cart -
    : 
else 
{ 
echo are no items in your 
echo 
} 
,      ,   -
   ,    -
. 
       HTML,  
  . 25.6  25.7.      outputjns.php  -
   25.10.    ,     -
  . 
 25.10   outputjns.php   
   _ 
function $change = true, $images = 1) 
{ 
//      
//  (true  false) 
//  (1  , 0  ) 
global $ i 
global 
echo border = 0 width = 100% cellspacing = 0> 
action = php method = post> 
<trXth colspan = (l+$images) 
#cccccc\ 
<th 

 25.    
//        
foreach ($cart as $isbn => $qty) 
= 
echo 
==true) 
echo align lef 
if 
$size = 
if ($size[0]>0 && $size[l]>0) 
echo border=0 
echo "width $size[0]/3 height = . 
else 
echo 
echo 
echo align = lef 
echo href = 
by 
echo align = 2) 
echo align = 
//   , 
//    
if change == true) 
echo type = name = value = size 
else 
echo 
echo align = 
//    
echo 
<th colspan = 
<th align center 
</th> 
<th align = center 
//    
if == true) 
{ 
echo 
<td colspan = (2+$images) 
<td align = center> 
<input type = hidden name = save value = true> 
<input type = image src = 
border = 0 alt = 
echo 

  5.     MySQL 
   ,   
1.          TSBN  
 get_book_details(),       
 . 
2.     ,   .  -
     ,   
  .     ,   
 ,      . (   
,        -
 gd,    19,      -
   .) 
3.         . -
        ISBN   
. 
4.   ,      true 
(      true   ), -
    .   ,  
 Save Changes. (      -
   ,      -
.) 
      ,    -
.      . 
    
       Add To 
Cart,        
.  ,      . 
-,        ,    
,    : 
{ 
$cart = array 0; 
= 0; 
= 
} 
  . 
-,  ,   ,     : 
if 
else 
= 
 ,       .  ,  
    .       
 . 

    
-,          
.      
= 
= 
        , -
,   25.12. 
 25.11   book_fns.php    
      _ 
function 
{ 
//    
$price = 
if (is_array 
{ 
$conn = 
as $isbn => $qty) 
{ 
= "select price from books where 
$result = 
if ($result) 
{ 
= 0, 
$price 
return 
 ,         
 ,   .    , , 
    ,  ,  (   ) 
   .      -
,    . 
 25.12   book_fns.php    
      _ 
function 
{ 
//       
$items = 
if (is_array 
{ 
as $isbn => $qty) 
{ 
+= 
} 
} 
return 
} _ _ 
        -
     . 

 5.      MySQL 
   
      Save Changes, -
  .      .  -
    ,   Save Changes  
  .      save.   
  ,  ,     
Save Changes.  ,      ,  
   . 
      ISBN ,   -
: 
text name = value = $qty size = 
   ,   : 
{ 
foreach ($cart as $isbn => $qty) 
{ 
else 
= 
} 
= 
= 
} 
         
    .     
( ). 
(     1.) ,    
   ,       
    Save Changes. 
      0,   -
      unset().     
       : 
if 
else 
$cart[$isbn] = 
       
      -
  
     
 ,         -
    .     
    
  ,      
 ,     ,  -
     .       

 25.    
= ""; 
  
     Go to Checkout (   
),   cheekout.php.       
    SSL,     
  . (   SSL    15.) 
    . 25.8. 
  ,      (  ,  
 ).   ,    ,   
 25.13. 
 25.13 cheekout.php       
//   
include 
//  
false, 
else 
echo are no items in your cart"; 
do html 
"Continue 
 25.8 
 cheekout.php 
  
Sams PHP4 In 24 by 
PHP Web by and Laura 
Zip Coda 
Country 
G4.99 1 24.9 
1 99 2 

464  5.       MySQL 
     .   ,   
 .     ,   . 
25.8. 
       Purchase   -
 ,   purchase.php.     . 25.9. 
 
 purchase.php 
  
  
  ,  
   
. 
I   
Sams PHP4 in 24 by 
PHP and 
Shipping 
TOTAL 
Card 
(if 
Please press Purchase to  
$ * 
to add or 
   checkout.php    .     
 25.14. 
 25.14 purchase.php          
   
include 
//  
//    
//     
echo "Could not store data, please try 
//     
//   
false, 

 25.    
  
"Continue 
} 
else 
echo did not fill in all the please try 
echo action = ' method 
//    ,  
//      
as => $value) 
echo type = hidden name value = 
ft 
"Back") 
echo 
) 
() 
  :  ,    , 
           
      .     -
 25.15. 
 25.15  insert_order()    
      
function 
{ 
global 
global 
     
 ,    
country) 
{ 
= 
$ship_address = 
$ship_city = 
$ship_state = 
= 
$ship_country = 
! 
$conn = 
  
= "select from customers where 
name = and address = 
and city = and state = 
and zip = and country = 
$result = 
= 0, 

466  5.      MySQL 
else 
{ 
= "insert into customers values 
 ', 
= 
if (!$result) 
return 
= "select customers where 
name = and address = 
and city = and state = 
and zip = and country = 
$result = 
if ($result) >0) 
= 0, 
else 
return false; 
$date = 
= "insert into orders values 
$result = 
if (!$result) 
return false; 
= "select orderid from orders where 
customerid = $customerid and 
amount > and 
amount < and 
date = and 
order_status = and 
ship_name = and 
ship_address = and 
ship_city = and 
ship_state = and 
ship_zip = and 
ship country = 
$result = 
$orderid = 0, 
else 
return false; 
//   
as $isbn => 
{ 
$detail = 
= "delete from where 
orderid = $orderid and isbn = 
$result = 
= "insert into values 
$result = 
if (!$result) 
return 
} 
return 

 25.    / 
   ,     -
 , ,       . 
            
   : 
      
 $20.        , -
           
. 
  ,        -
     
 
      Purchase,   
        
  . 25.10. 
 25.10 
  
    
. 
Ed* 
 . 
^. 
1 " 24.99 
< 
.. 
for us. Your 
     
 25.16 process.php         
 
include 
//  
) 
   , 
  
false, 0) 

468  5.       MySQL 
{ 
 
echo "Thank you for shopping with us. Your order has been 
"Continue 
} 
else 
{ 
echo "Could not process your card, please contact the card issuer or 
try 
} 
} 
else 
{ 
echo "You did not fill in all the please try 
echo action = method = 
echo type = hidden name = from value = 
//      
//    
as => $value) 
echo type = hidden name = value = 
echo 
} 
() 
  ,  ,   -
  : 
{ 
  
echo "Than kyou for shopping with Your order has been 
"Continue 
} 
    ,      
     -
  .      . 
         -
  true. 
     ,     
.   : 
     .    -
,    .     -
    .     -
   .     , 
 , .      .   -
         
. 

 25.    469 
       -
 , ,   PGP  GPG,    -
 15.         
 . 
        .    
 ,         . 
     15. 
        . 
   
       .  
   Web-    , -
  .    ,    24. 
     . 
  ,       
     ,  
     . (     
       24.     CD-ROM.) 
    . 25.12. 
 25.11 
   
 
   
  . 
 25.12 
   
 
 
. 
 

 /  5.       MySQL 
      25.17. 
 25.17 admin.php      
        
//  
if 
//       
{ 
{ 
// 
//     
= 
} 
else 
{ 
//      
echo "You could not logged in. 
You must be logged in to view this 
exit; 
if 
display 
else 
echo "You are not authorized to enter the administration 
      24.      
             -
 24    . 
 -      
     check_admin_user().    
,   ,    
       , -
     -
    .   -
    ,  
 ,       .   -
,    ,        
 . 
    . 

 25.    471 
 25.13 
   
  
   
 . 
mm  1  
Add a book 
Book I 
Book Author 
Price: 
 ,   Category   HTML- SELECT. 
          
    Add Book ( )   
     25.18. 
 25.18 -      
        _ _ 
//   
a 
if 
{ 
if 
{ 
$title, $catid, $price, 
echo "Book was added to the 
else 
echo "Book could not added to the 
} 
else 
echo "You have not filled out Please try 
"Back to administration 
} 
else 
echo "You are not authorised to view this 
 ,         
,   ,    

  5.      MySQL 
     ,    -
      .    
       
.       Go to main site (  -
 )   ,    (  
        -
  ,    .      . 
     .    
 ,   ,     
,        -
   .   . 25.14. 
       : Edit 
Item ( )  Admin Menu ( ).  , 
          Log Out ( 
 ). 
     (  25.8): 
) 
{ 
"Edit 
"Admin 
display "continue", 
} 
     ,     -
  . 
      Edit Item,  -
     . 25.15. 
 25.14 
  
 
  
. 
Help 
. 1 
i Back   
PHP and Web 
Author: Welling 
Price: 39 
PHP & MySQL Web the secure  
You learn to and these by 
sample 

 25.    473 
 25.15 
 
edit 
 
 
  , 
  . 
 1 . V i | if . 
 
Edit 
Book 
Price: 
Description; 
details 
|PHP and MySQL 
Welling and 
& MySQL Web Development the to 
develop dynamic, secure web sites. You 
[will learn to integrate and 
k 
Back i 
,    ,       
.           -
.         .  -
  25.19. 
 25.19  display_book_form()     
       
function = 
//   . 
//      . 
//        
//    . 
//      . 
//  $edit   
//    
//     
//   .     
//     
//  ,   "Delete 
    
//   
$edit = 
//     HTML- 
//    - 
method=post 
border=0> 
<tr> 

  5.       MySQL 
</tr> 
<tr> 
</tr> 
<tr> 
</tr> 
<tr> 
<? 
//     
foreach ($cat_array as 
{ 
echo 
echo 
echo 
//    
//    
if ss 
echo 
echo 
echo 
echo 
} 
?> 
</select> 
</tr> 
<tr> 
<td>Price:</td> 
<tdXinput 
: 
</tr> 
<tr> 
<tdxtextarea cols=50 
?> 
</tr> 
<tr> 
<td <? if echo ?> align=center> 
<? 
if ($edit) 
//  ISBN,      
//    ISBN 
echo 
<input 
?> 
<? 
if ($edit) 

 25.    4 / 
echo 
echo 
echo 
echo 
</tr> 
  ,   ,     
,     : 
name=price 
     . ,   -
       ,     .  -
      -
  . 
  ,   ,    -
,    .     , 
  ,    . (    
 .)        ,  
   7.   ,   ,  , 
   "".     ,   -
      . 
     .   -
     ,    CD-ROM. 
 
      .  -
    : 
        -
   .       -
  . 
         -
    .   ,  -
        .  -
        
  ,       
. 
           
     .    , 
        . 

476  5.      MySQL 
    ,  
,  ,  ,   
 ..   . 
   
       -
   ,   - 
 .         -
          -
  : 
    ,    -
,    ,   ,  
         -
.   (    )     3 
     PHPLib. 
,     -   ,  -
  .         
    . 
  
        
.        
 ,      ,   -
. 

 





 


      
 , ,    
   . 

     
 Web-,      
 ,     
 ,     
     . 


  ,   
    
   . 

 : 

  Web-     
   ,   
     
 

,   Web-  
SuperFastOnlineNews      
-.     
 ,   .   
       
 . 

  SuperFastOnlineNews   
  .     
 . ,   ,   
,       
Web-, 


47   5.      MySQL 
         
 ,     ,  
 . 
   
  , : 
   ,     
,      
          
         
          -
 
          
     
  
-,       ,   
    . 
   
       .  
 . 
FTP 
       Web-.  
         .  -
       ( -
    ).     -
  Web ,       
 FTP   .    -
        -
  . 
   
    16, HTTP-     
  Web-.        . 
           
 .           
   ,        . 
       . 
        . 
  
         
   .        -
  ,       . 

 26.     
  ,   . Web-   - 
  ,     , -
  . ,      -
, ,   ,     
. 
     ,        
   . 
        
         -
      . 
     ,    -
     .  MySQL   -
 ,        -
.     ,     
(BLOB)    MySQL   . 
        .  <IMG 
        . 
   ,    .  ,  
      ,   
      . 
    . 
 26.1 
  
  
  . 
 / 
 / 
 / 
 d/ 
ajs23.jpg 
cp331.jpg, clo95.jpg 
 
/ yo224.jpg, yz775.jpg 
      ,   -
   .  , 10000    26 . 
      400 .   -
     ,   10000     
.  ,       -
   ,    . 
   . 26.1 ,        
 . 
  
        , -
 -    .    ,  
.    ,      
. 

 U  5.      MySQL 
    ,      -
,    .       
   . 
     .      
   .       -
 . 
    ,     
    ,        
 ,   . 
         
 .  ,        
       .    
        -
         . 
 
 ,       ,   -
.           . 
   ,    -
   .       -
       ,     
  . 
 ,     ,  
.      ,  -
     . 
            
    .    -
    .     -
      . 
          
,       "" ,  
      1  10. 
     ,   -
     .    
,         -
    ,     -
. 
  ,      .   
  HTML- <>    XML  -
 .       -
     . 
  
        ,  -
 .     , -
.  ,    ,    
,     .      -
 ,      . 

 26.     1 
 . 26.2    ,    
 26.2 
  
. 
<TABLE> 
<TRxTD 
<TRxTD> 
Side menu 
MAIN CONTENT CELL 
          -
,     ,     ?   
       . 
  ,  ,     
,  .  HTML-    <TD>,  
  .    HTML-    . 
    ,     .  
 ,   ,   , ,  
. 
         -
  ,   . 
    ,     . 
       
  ,      
 . 
   .   ,   
     ,   
<? ?> 
      - ,  -
  ,      Web-.  , 
    cookie-     -
  4,   cookie      
  Web-. 
  
     .   -
 ,   ,       
 ,       ? 
16 

482  5.       MySQL 
  ,       -
,     JPEG   --
   .       19. 
       -
 ,          
<IMG     26.1. 
 26.1    JPEG- " " 
<? 
if 
= 150 
if 
= 100; 
$size 
= 
$height = 
$x_ratio = width / 
= $max_height / 
if ( <= ($height <= ) { 
$tn_width = 
$tn_height = 
} 
else if ( * $height) < $max_height) { 
$tn_height = * 
= 
} 
else { 
$tn_width = * 
= 
} 
$src = 
$dst = 
$src, 0, 0, 0, 0, 
null, 
        ,  
    .   ,      
200  200,        .  
     ,   -
   . ,   400  300  
   200x150.      -
. 
     ,    
 HEIGHT  WIDTH   <IMG SRO.   -
       .    
   ,      100 .  -
    ,      -
 . 

 26.     
       19.  
      . 
         -
  .       -
.   $max_height       -
.     ,     
. 
$x_ratio = / 
$y_ratio = / 
      ,    
  .       X 
 Y     ,   -
      : 
if ( <= <= $max_height) ) { 
width = 
= 
} 
if * $height) < { 
$tn_height * 
width = 
} 
{ 
$tn_width = * 
height = 
} 
  
 . 26.1     . 
 26.1     
  
SQL 
select_fns.php 
header.php 
footer.php 
page.php 
SQL-       
 
       
       
 
       
SELECT 
      
       
 
       
 
  ,   header.php 
 
 
     
 
       
 

  5.       MySQL 
  
resize_image.php  
togout.php 
 
 
 
 
 
 
       
       
  
  ,  
  
     
    
    
 ,     
.    , 
    
     ,  
   
       
 ,    
    ,  
  stories.php 
         
   
     
   
     , 
   
     ,    
,      
   
   ,   
 
    , 
   
 
 
delete_story.php  
keywords.php  
 
keyword_delete.php  
 
 
 
   
 26.2  SQL-,      
 .       
  CD-ROM        
    . 
 26.2  create_database.sql  SQL-    
  
drop database exists content; 
create database content; 
use content; 
drop table if exists 

 26.     
create table writers ( 
primary key, 
password not null, 
text 
drop table if exists stories; 
create table stories ( 
id int primary key 
writer not null, #   
page varchar(16) not null, #   
headline text, 
story_text 
picture text, 
created int, 
modified int, 
published int 
drop table if exists pages; 
create table pages ( 
code primary key, 
description text 
drop table if exists 
create table ( 
writer not null, #  
page not null #   
drop table if exists keywords; 
create table keywords ( 
story int not null, #  
keyword not null, 
weight int not null 
grant select, insert, update, delete 
on * 
to identified by 
      ,     
,   writers.         
 ,        . 
 pages    ,    -
 .        -
,       . 
 stories      headline (), 
( )  picture (),     .  created 
(), modified ()  published ()  -
       UNIX . 
       : 
-u root < 

486  5.      MySQL 
 
,        ,   
  . 
  
       26.3.   
     .  -
      . 
 26.3  headlines.php      
<? 
include 
include 
$conn = 
$pages_sql = "select * from pages order by 
= 
while ($pages = { 
$story_sql = "select * from stories 
where page = ' $pages ' 
and published is not null 
order by published 
$story_result = 
if ) { 
$story = 
echo 
echo 
echo 
if 
echo 
echo 
echo 
echo 
echo 
echo 
echo 
echo 
echo 
echo SIZE=l>Read more 
echo 
echo 
include 
?> 
 ,     ,   
   footer.php  .    ,  -
,      . 
      .  
select * from pages order by code 
  ,    .     

 26.     
* from stories 
page = $pages [code] 
and published is not null 
order published desc 
         . 
 . 26.3       -
. 
 26.3 
 
  
 . 
The Top News From 
Around the World 
gives 
Sports Latest - All The Winners 
and Losers 
Up To The Minute Weather 
Reports and Forecasts 
Storms to 
 
        : 
SIZE=l>Read more . 
         
     .     -
  ,   page.php.     
  .   page.php    26.4. 
 26.4  page.php       
<? 
include 
include 
$conn = 
if { 
exit; 
$sql = "select * from stories 
where page = ' 
and published is not null 
order published 
$result = 

   5.      MySQL 
while ($story = 
{ 
if { 
$size = 
= 
$height = 
echo 
> 
echo 
$w = 
echo 
echo 
echo d, 
echo 
} 
include 
 ,       -
     .  
 ,   ,    
if (!$page) { 
exit; 
} 
     ,    
   . 
  
select from stories 
where  = 
and published is not null 
order published desc 
  ,    ,    -
   (     ).   
       ,    
    . 
 . 26.4    .      
 ,     . 
  
     .    -
        
            -
,    ,     -
.    . 26.5. 
         ,  
  .        , 
         -
  .   stories.php    26.5. 

 26,     
 26.4 
  
 
  
 
. 
Man gives birth 
A man today gave birth in a hospital on Staten Island. NY. baby boy 
weighed over pounds and is doing well. The were 
naturally overjoyed at the birth of their first son, have said they 
hope to have a large 
Father Ted. conceived using a new known as 
whereby the fertilised embryo is transferred to the body at an early 
It is believed that this method many of the risks of childbirth. 
William 
Reports are coming in of a fire in a barn in Arizona. Our 
sources say the barn is very to burn to the ground and will not be economically 
viable to repair. 
bystander is reputed to have said was quite a lot of smoke" 
 26.5 
 
 
  
. 
Warning: Cannot send session cache foniter - headers already sent started 
in on 11 
Welcome. Billings 
stories: 
Man gives birth 
Fire! 
Launch Party report 
Storms to come 
mollified 
news Dec Dec 12, 00:15 11. 
news 11. 19:19 22:03 Dec 21:30] 
news Dec 11, Dec 
11. 11. 
weather is Dec 10, Dec 10. 14:32 Dec 1.0. 

490  5.      MySQL 
 26.5  stories.php  ,    
   
<? 
include 
if { 
?> 
SIZE=16 
<TD>Password</TD> 
SIZE=16 
</TR> 
<? 
} 
else { 
= 
$w = 
echo "Welcome, 
echo 
echo 
$sql = "select * from stories where writer = 
"order created 
$result = 
echo "Your 
echo 
echo (<A 
echo 
if 
echo 
echo 
echo 
while ($qry = { 
echo 
echo 
echo 
echo 
echo 
echo 
echo 
echo 
echo d, $qry [created] 
echo 
echo 
echo d, 
echo 
echo 
if 
echo d, 
else { 

 26.     
echo 
echo [<A 
echo 
echo 
echo 
echo 
} 
   ,   .  , 
    . 
        -
.      .    -
 ,      -
.       14. 
       
       .   -
        -
   ,     -
    . 
          
.          -
      . 
$w = 
echo "Welcome, 
echo (<A 
       
       .  
    $auth_user. 
 SQL-    ,     -
 : 
select * from stories where writer = 
order by created desc 
  ,   ,    , 
  .    ,    -
    .    
      . 
          : 
echo d, 
: 
echo d, 
, : 

      MySQL 
if 
else { 
echo 
echo 
echo . 
} 
     ,    .  
        ,  -
     . 
          
 . 26.6        -
  . 
 26.6 
 
. 
report 
the 
contain tags) 
gone in the day Che site on the 
boogie several celebs to remain 
Or HTML 
   story.php    26.6. 
 26.6  story.php       
<? 
include 
if 
$s = 
TYPE=HIDDEN echo 
echo 
<TD 
SIZE=80 
echo $s [headline] 
</TR> 

 26.     
<TD 
</TR> 
<TD 
"select 
from pages p, w 
where = 
and w. writer= , $s 
text (can contain HTML 
</TR> 
<TDXTEXTAREA COLS=80 
echo $s [story_text] 
</TD> 
<TD upload HTML file</TD> 
</TR> 
<TD TYPE=FILE 
<TD 
</TR> 
<? 
if { 
$size = 
$height = 
?> 
<TD 
echo 
WIDTH=<? echo HEIGHT=<? echo 
</TD> 
</TR> 
<? } ?> 
<TD 
</TR> 
</FORM> 
            
.     ,    
   . 
if 
$s = 
    db_fns.php.   -
        .  

494  5.      MySQL 
  ,    NULL,   $s  -
  . 
SIZE=80 
    ,     
    ,      .  
  ,      -
 . 
echo 
"select 
from pages p, w 
where = 
and = , 
    select_fns.php.   HTML-
   SELECT    SQL-.   -
   NAME   SELECT. SQL-    
  ,     VALUE  ,  
    OPTION    ,  
 .   .    SELECTED  , 
    . 
  -      -
         
story_submit.php ,       
    SQL- UPDATE  INSERT. 
     26.7. 
 26.7         
  
// story_action.php 
//   
include 
$conn = 
= time 
if ( && == "text") ) { 
$fp = 
$story_text = 
} 
if ($story) { //  
$sql "update stories 
set headline = 
story_text = 
page = ' 
modified = 
where id 
> 
else { //    

 26.    4  
$sql = "insert into stories 
(headline, story_text, page, writer, created, modified) 
values 
$time, 
} 
$result = 
if (!$result) { 
echo "There was a database error when executing 
echo 
} 
if ( ($picture) && ($picture != "none") ) { 
if (!$story) 
$story = 
= 
switch { 
case 
case = 
copy ($picture, 
$sql = "update stories 
set picture = 
where id = 
$result = 
default: echo "Invalid picture format: 
?> 
    delete_story.php.    
 DELETE      .   
   26.8. 
 26.8  delete_story.php      __ 
<? 
// delete_story.php 
include 
$conn = 
$now = time () 
$sql = "delete from stories where id = 
$result = 
  
            
    ,   .     
.      .   -
     . 

496  S.      MySQL 
 26.7 
  
  . 
-. P  
Keywords for Party 
launch 10 
party 10 
SFON 8 [; 
celebrities 5 
boogie 3 
 . 26.7  ,      -
 . 
  ,       -
.     CD-ROM. 
      -
     . 
         -
  : 
into keywords (story, keyword, weight) 
values ($story, $weight) 
  ,     -
   : 
delete from keywords where story = $story and keyword = 
        
     . 
 ,     
           
      .   search.php 
   26.9. 
 26.9  search.php        
     
<? 
include 
include 
$conn = 

 26.     
if { 
$k = 
= 
for $i++) { 
if <$i) 
.= "or = 
else 
$k string .= = 
} 
.= "and ($k_string) 
} 
$sql = "select s.id, 
10 * sum (k. weight) / as score 
stories keywords k 
where 
$and 
group by 
order score desc, s.id desc"; 
$result ($sql, 
echo 
if { 
echo 
while ($qry { 
echo 
echo 
echo 
echo 
echo 
} 
echo 
} 
else { 
echo "No matching stories 
include 
   ,   ,   -
   .      -  -
 ,      AND  OR,  -
   . 
if { 
$k = split 
= 
for $i++) { 
if <$i) 
$k_string .= "or = 
else 
$k_string .= = 
} 
$and .= "and ($k_string) 
} 
    PHP-   , -
     .     
,     ,    

       MySQL 
  .   ,      -
  : 
and = or keyword = ' or 
= 
   ,     : 
select 
10 * / $num_keywords as score 
from stories s, keywords k 
where = 
and = 
or = ' 
or = 
group by s.id, 
order by score desc, desc 
         -
  ,        -
  .     ,    -
      . 
      1  10,  
     100.      
   ,          
   10. 
  
    ,    
   .      -
 26.10. 
 26.10  publish.php    ,  
     ,      
  
<? 
include 
$conn = 
$sql = "select * from stories order modified desc"; 
$result = 
echo 
echo 
echo 
while ($story = { 
echo 
echo 
echo 
echo d, 
echo 
if { 
echo 

 26.     
{ 
echo 
} 
} 
echo 
       ,  -
   .      .    -
     .     -
  . 
       ,    -
   ,     .  if  -
     .    -
,       . 
      , ,  
unpublish story.php,  
   SQL-: 
update stories set published = $now 
where id = $story 
          . 
 ,    ,  
          
: 
update stories set published = null 
where id = $ story 
       , -
       .       
 ,        . 
  
    ,    -
   : 
       . 
     ,    -
     . 
   ,      -
.  ,  ,   ,   -
    . 
       .  
   , ,  aspell. 
 
      Web ,   
       Web   IMAP. 

 
 
  Web 
      -
   ,   Web.  
     
     --
 IMAP.      -
      Web-
.  ,     
     
Web ,  Hotmail. 
       
Mail,     -
: 
       IMAP 
     
    
   
     
    
       
 
     , 
       
.       Web--
 . 
     -
,       
  . 

 27.     Web 
         -
   :   
 ,       . -
   Post Office Protocol ( )  3,    
Internet Message Access Protocol (    Internet). 
      ,      
 ,       -
     .  IMAP   -
           
 ,    .  IMAP  -
  ,      . 
        RFC (RFC 1939  
  RFC 2060  IMAP 4.1).      -
    : 
             -
  SMTP (Simple Mail Transfer Protocol    
  ),      PHP-  -
       RFC 821. 
  
     IMAP  ,   -
    IMAP.     , -
   IMAP. ,      , -
      
   ,    .  
    FTP  : 
  UNIX         -
 .      mail.h  
     ,   
,     ,  -
  . 
       Windows,  
 ,    UNIX.   Windows  -
 .    ,    
 ,   : 
 ,    ,   
     NNTP (Networks News Transfer Protocol -
   ).       IMAP 
 ,   Warm Mail      NNTP. 
     ,     -
    .      . 
         -
  ,    . 

  5.     MySQL 
     ,   
  .  ,      -
.    IMAP,    : 
 
 
 
 imap_header () 
 
 
 imap_delete () 
 
     ,   -
      .       
  ,          
 . 
         (- 
      ).     -
     .    -
           
. 
     ,   , -
    ,    .  
      IMAP  ,   -
    SMTP   
,     . 
  
   Web       -
 . -       . 27.1. 
 27.1 
  
Warm Mail 
 
 
  
   
 . 

 27.   ,   Web 
   ,      ,   
   .        -
     .  ,   -
  ,   , , ,  -
   . 
       -
    .    -
    .  ,     
       
 ,          
           -
.  ,       , 
 ,     . 
       .  
 ,     ,    
 , index.php,        -
  .    ,  -
 ,    index.php,    .  -
     ,    
 .  ,    . 
     ,  .   
   ,     
.         
   ,   . 
   Warm   . 
 27.1  
 
index.php 
 Warm Mail 
  
  ,   
 
     
     
 
       mail 
        
  ,    . . 
     HTML- 
     
SQL SQL-    book_sc   
 
   . 
   
    Warm Mail  ,     -
    . 

     MySQL 
     .    
   : 
       Warm Mail. 
 password    . 
 address      ,   
   From ()    . 
  "" ,      
 . 
 ,       : 
 username    Warm Mail,    . 
 server  ,     . ,  
 port  ,        
 .   -      
 143. 
 type  ,        
 
        . 
 accountid       . 
      SQL-,    
27.1. 
 27.1  SQL-     mail 
create database mail; 
mail; 
create table users 
( 
username not null primary key, 
password not null, 
address not null, 
displayname not null 
create table accounts 
( 
username not null, 
server not null, 
port int not null, 
type char (4) not null, 
remoteuser not null, 
not null, 
accountid not null primary key 
) 
grant select, insert, update, delete 
on 
to mail@localhost 
,   SQL-  ,   : 
-u root -p < 

 27.   ,   Web 
      (root).  -
         -
 create_database.sql  db_fns.php. 
  CD-ROM      -
        . 
    ,   -
 .         -
  .     .   
,         . 
  
  ,        - 
     27.2.   ,   -
   . 
 27.2 index.php -   Warm Mail 
<? 
//    Warm 
//    
//     
//   
// // 1:   
//      
//      
//    
include 
= 
//    ,   - 
//    
$status = '' 
//  ,      
//   
{ 
{ 
$status .= in 
$auth_user = 
} 
else 
{ 
status .= we could not log you in with that 
and 
> 
} 
{ 

  5.       MySQL 
    
//   
switch ( $action ) 
{ 
case ' : 
{ 
} 
case : 
break; 
} 
case : 
{ 
//     
//      
{ 
$selected_account = 
// ,    
= 
= 
= 
log-out        
if (check 
{ 
$buttons[4] = 
} 
  
//  HTML-   
//    
{ 
//      
//     
"Warm Mail -
} 
else 
{ 
//       
"Harm 
} 
   
//   ,    
 ,  , 
//    
echo 

 27.  ,   Web 
{ 
echo need to log 
echo to go to 
echo . 
} 
else 
{ 
switch ( $action ) 
{ 
//      
//     
//      
case : 
case : 
case : 
break; 
} 
case : 
{ 
if $cc, 
echo sent 
else 
echo not send 
} 
case : 
{ 
//      
     case 
> 
case : 
case : 
{ 
//    ,   
break; 
} 
case 
case : 
case : 
{ 
//       ,  
//        
//   
$fullheaders = 
( 
case : 
{ 
//   $     
//   (carbon copy) 
$imap = 

 U   5.       MySQL 
$header = 
= 
= 
$cc = 
= 
$body = 
display $cc, 
break; 
} 
case : 
{ 
//    reply-to  
// () 
= user, 
{ 
$header = 
$to = 
else 
$to = 
= 
$body = 
$to, $cc, 
} 
break; 
} 
case : 
< 
//        
//  
= 
{ 
= 
= 
= 
display $to, $cc, 
} 
} 
case : 
{ 
$to, 

 27.   ,   Web 
//   
?> 
      .    
     .    -
  ,      . 
    display_button(),   
     (submit).   
   output_fns.php.    URL- : 
     , 
    . 
     : 
1.   ,     -
  .    ,  -
         
. 
2.          -
  . 
3.         -
 .     . 
4.    . 
 ,      . 
       , -
 . 
     
     ,  
 . 27.2. 
 27.2 
     
 Warm Mail 
  
  . 

  5.      MySQL 
    .      
 (   )     
  ,     . 
      : 
   ,      -
       -
 . 
    ,    -
   .     
= 
   ,   : 
= 
= 
= 
     : 
"Warm Mail", 
         ,  -
  . 27.2.     -
       ,   -
  . 
    : 
{ 
echo need to log in" 
echo to go to 
echo 
      
      ,     -
.  ,    ,    , -
  . 27.2.     -
 
        Log In ( 
 ),  ,   . 27.3. 
       .  
    ,     -
,      : 
{ 

 27.   ,   Web X 
.= in successfully 
= 
else 
$status .= we could not log you in with that 
and 
 ,     ,   
  24  25.         
  $auth_user. 
 ,     ,  , -
    : 
{ 
= 
} 
 Log Out   . 27.3. 
       .     
 ,  : 
echo 
          
. 
   
       Warm Mail,  -
   .     Account Setup ( -
 ),    account-setup   
       . 27.4. 
 27.3 
    
  
   
. 
" ' ] 

512  5.      MySQL 
 27.4 
   
 , 
   
   
. 
     27.2.      
  . 
    : 
($auth_user, "Warm Mail -
    : 
case : 
case : 
case : 
display 
break; 
       .    
  display_account_setup().      27.3. 
 27.3  display_account_setup()  outputjns.php 
       
function 
//    "new account" ("  ") 
$list = 
//     
as $key => $account) 
//     
//         
//   
//     

 27.   ,   Web 
          
.    ,     -
 .   ,   
. 27.4.  ,     :     
   ,        
  .       
  HTML-    . 
       
     27.4. 
 27.4  get_accounts()     
     _ _ 
function 
{ 
$list = array () 
if 
{ 
= "select * from accounts where = 
$result = 
{ 
= 
$list, 
} 
else 
return 
} 
return 
      ,    
        . 
    
           
Save Changes ( ),   store-settings. -
          -
   : 
case : 
{ 
17 216 

  5.       MySQL 
        
.       27.5. 
 27.5  store_account_settings()    
     _ 
store $settings) 
{ 
{ 
"All must be filled in. Try 
return 
> 
else 
{ 
"update accounts set server = 
port = type = 
= 
= 
where accountid  
and 
else 
- "insert into accounts values 
< 
return 
> 
else 
{ 
echo "could not store 
return false; 
           -
.       . 
         -
    index.php: 
case : 
case : 
case : 
{ 
display account 
break; 
} 
,   ,     -
    .      -
   . 

 27.  ,   Web 
   
        . -
        Save Changes.    -
  store-settings.       -
  ,        . 
   
      Delete Account (  -
),       .   -
  delete-account. 
    index.php   : 
: 
{ 
break; 
} 
       27.6. -
       ,   
       .  
   ,      . 
 27.6  delete_account()    
   _ 
function $accountid) 
{ 
//        
  
= "delete from accounts where 
and 
= 
{ 
= 
} 
return 
          
index.php.     : 
case : 
case : 
case : 
{ 
break; 
} 
            
. 

516 5.      MySQL 
   
       ,    
           . 
   
        .   
    
       ,  
     : 
{ 
$accounts = 
= 
} 
 number_of_accounts()  mail_fns.php    -
,       .  
     .     .  
       0. 
    27.7. 
 27.7  number_of_accounts()  mail_fns.php , 
     _ 
function 
{ 
//  
//  
= "select from accounts where = 
{ 
$result = 
if ($result) 
return 0, 0) 
} 
return 
      
 ,      . 
     ,   
    .        
SELECT,      .      
    ,    . 
27.5. 
  SELECT     
     : 
<? 
//       
//     

 27.   ,  Web 1 / 
{ 
echo bgcolor = align right valign = 
echo 
echo 
    HTML-,     
.   HTML-,   display_account_select() -
 . 
      ,  
display_account_select()  HTML-  : 
<select 
<option value = 0 selected> 
Choose Account</a> 
<option value = 
</option> 
<option value = 
</option> 
<option value= 
localhost 
</option> 
</select> 
     ,       
  JavaScript.  ,    HTML-,  
        . 
 27.5 
    
SELECT  
 localhost 
  
 
 
 . 
N Warm Mail 
N PHP (830 
for a 
f chars 

        MySQL 
      , JavaScript-  
   .    -
   SELECT,   window.location    
      -
      JavaScript  
 JavaScript- ,      . 
 display_account_select()     
     .  ,   -
   
       SELECT   
   . 27.5,   window.location  
 URL-      . 
  . -,     (-
        
: 
: 
{ 
//   
//     
{ 
= 
-,      , -
 : 
case : 
case : 
{ 
//       
//  view   
} 
   ,       View 
Mailbox,     . 
  
        
      .     -
 27.8. 
 27.8  display_list()    
   _ 
function $accountid) 
< 
//       
global $ 

 27.   ,   Web 1 
echo "No mailbox 
else 
= 
echo width = cellspacing = 0 
cellpadding = 6 border = 
= 
//       
//      
//     ,  
//    echo 
= 
echo bgcolor = 
if($i%2) 
echo 
else 
echo 
echo ' href 
echo 
echo 
} 
echo 
else 
$account = 
echo "could not open mail box 
. $account ] . 
     IMAP- .  -
         . 
         -
   mail_fns.php.      27.9. 
 27.9    
     
function $accountid) 
{ 
//   ,    
user)==l) 
{ 
$accounts = 
$selected_account = 
$accountid = 
//       

520  5.      MySQL 
= 
( ($settings) ) return 0; 
= 
.= 
. = 
// 
@ = 
return 
      imap_open().   
 : 
(string mailbox, string 
string password [, int 
  ,    : 
 mailbox          ,  
, ,     .    
 : 
   ,      
   , ,      
   ,     . 
,         -
 ,      : 
     : 
 username       
 password      
 ,       ,  
 "open mailbox in read-only mode" (     "  
"). 
 ,   mailbox    -
      .    -
,  ,   {$,    4  -
. 
         -
  ,   false   . 
           -
 

 27.   ,   Web 
        -
.        
    : 
$headers = 
         
,    .     -
,     .   .  
 ,    . 27.5. 
         , 
          -
 imap_headers()    . 
   
 ,   display_Iist(),     
   . 
    : 
 mcssagcid    ,  
   .  ,   
  ,    . 
        ,   
 . 27.6. 
, 
 27.6 
   
view-message  
 . 
    
   1  ill 
 
is a MONEY MAKING It not you come Into with do any hard 
best you have to leave except to the you that get big been 
THIS 13 the and dreams come e-mail order program 
works 
perfectly, TIME. 
The following income opportunity one you ay be taking a at. be with very investment and the 
Income return is TREMENDOUS! 

 5.      MySQL 
        : 
case 
case 
{ 
//      ,   
//      
//   
$.ullheaders = 
$selected_account, $messageid, 
$fullheaders) 
} 
       
   false      -
 false.    . 
 
$fullheaders = 
    , , ,   : 
if 
= true 
= false; 
   display_message().     -
  HTML-,    .   -
       : 
$message - $accountid, 
       
  
 27.10    
     _ 
function $accountid, 
{ 
$ = array () 
&& && 
return 
= 
return 
= 
if 
return false; 
= 
= message has no 

 27.   ,   Web 
= 
= ' 
= 
-
= 
= 
= 
//    
//       to 
//  toaddress,   
return 
-,       open_mailbox(). 
          
       . 
     
         
  imap_headers.    .    
 : 
 imap_headers()        
   ,      . 
imap_header()        
. 
        
. 
    imap_header()     -
 , a     ,   
. (     .) 
  imap_body()    ,  
   . 
 imap_header()   : 
$header = 
       : 
= 
        
= 
,  imap_close()       
.        -
  ,   . 27.6. 
   
 . 26.7    Show Headers ( ).  -
  show-headers,       -
 .         . 27.7. 

524  5.       MySQL 
 27.7 
 
  
  
,  
 
 
 . 
 Mi I 
'. '  
. 
0 
Is a MONEY 
  view-message    show-headers (  -
  hide-headers).    ,    , 
  .      
   : 
= 
     . 
   
    Delete      
  delete.       
 index.php: 
case : 
{ 
//       
//     case 
case : 
case : 
//         
//   ,   
$selected 
break; 
} 
     ,   -
    ,   . 
     

 27.   ,   
 27.11  delete_message()  mail_fns.php  
     
function $accountid, $message_id) 
//    
= 
{ 
return 
} 
return false; 
         imap_delete()  
 ,     -
  .     .   -
    . 
  
,    .     -
 :     ,   , 
   .    . 
   
    ,    New Message ( 
).      new-message,  -
     
case : 
$cc, 
break; 
> 
        .  
   . 27.8.       , 
     . 
     Send Message   send-message, 
   : 
case : 
{ 
$cc, 
echo 
else 
echo not send 

526  5.       MySQL 
 27.8 
  
   
 
3 
> is a LEGAL, MONEY OPPORTUNITY. It does not 
require you to come into contact with people, do any hard work and 
of all, you never have to leave the house except to the mail. If you 
believe that someday you'll get that big break that been waiting 
for, THIS IT! Simply follow the and your dreams will 
come This order 
> perfectly, EVERY 
> The following income opportunity is one you be in 
taking a look It can be started with very little investment and 
   send_message(),    -
.      27.12. 
 27.12  send_message()  mail_fns.php  
   
function $cc, $subject, $message) 
//      
global 
if ) 
return 
} 
"select address from users where 
$result = 
if (!$result) 
{ 
return 
else if 
return 
else 
$other = "From: 0, 
if 
return true 
else 
return 

 27.   ,   Web 
 ,         
        
   .       From (). 
      
 Reply (), Reply All ( )  Forward () -
     ,    New Message.  -
          
.   . 27.8.      -
.         Subject () -
  .  Reply  Reply All    -
  ,           
. 
       
: 
{ 
   
= 
{ 
$header = imap 
$ to $header->reply_toaddress 
else 
$to e 
$cc 
= 
$body = 
display $to, $cc, 
} 
case 
{ 
      From 
= open $selected 
{ 
$header = 
$to = 
else 
$to = 
= 
$body 
user, $to, $cc, 
break;  

  5.      MySQL 
case : 
{ 
 ,   
= 
{ 
$header = 
= 
$to, $cc, 
} 
} 
      ,  -
       . 
     Web- -
  . 
  
      .  -
      .  -
    : 
      . (  -
        24.) 
       , , 
  .       -
         -
  .        -
 .         , 
    . 
   ,      -
.     ,  -
   ,       16.   
     28. 
     
    .   NNTP-  -
  IMAP        -
 .      imap_open()   
   .      INBOX 
   ,     .  -
        29   
Web-  ,    . 
  
    ,    . 
 ,       -
  . 

28 
 
  
 
      Web-, 
     -
   ,   -
.        -
  (mailing list manager,   MLM). 
 MLM    -
   .   -
     -
,       
.    
       
 .    -
        
     
      -
       . 
    ,  
     HTML- -
 ,    -
.  ,    
     -
   . 
     , 
   ,  ,    
      -
   HTML. 

  5.     PHP  MySQL 
 
        -
 .         -
       -
      . 
 ,     : 
         -
. 
       -
       HTML      
 . 
          
    . 
        , 
  . 
         -
  . 
        -
      HTML    
 . 
          
         -
    . 
        -
   . 
        -
  ,    (). 
  
      . -
     ,    
 ;   ,   
   ;      -
. 
    
         , 
    ,    .    -
         
     HTML,     -
   . 
  ,     -
        . 
        -
 .      , , -
,     .       

 28.     
 ,     ,  
  . 
     MySQL         -
     . 
  
  ,   ,  
  .        ,  -
    .    ,   
       .  -
  ,       -
  ,      Web-.    -
      HTML. 
        , -
   16. 
      ,  ,  -
 . ,      ,   
HTML  ,    ,   HTML. 
     ,   
,      .   -
       . 
      
   ,       
            "" 
  HTML-       -
   .  PHP-   
   .      -
   HTML MIME Mail,    (Richard 
Heyes).      HTML-   -
   ,   HTML-. 
        Web- 
(        CD-ROM.) 
        .    
    .     
    Web-. 
  
         
   ,       27. 
  ,  ,   ,  -
 ,      .   
          
.      ,    -
  ,       

532  5,      MySQL 
     .   , 
,  . 28.1, 28.2  28.3. 
 28.1       
. 
 
 
 
 
 
 
 
 28.2          
  . 
 
 
 
 
 
 
 
 
 
 
 
 28.3     

 28.     
 . 28.1  ,     
.  ,    (    -
),    (     )    -
,    (    ). 
,      ,  
 . 28.2.         ( 
   ),        
,     . 
,    ,   . 
28.3.  ,    ,   
 ,     .  
    ,      -
         . 
      , -
          
 .        . 28.1. 
 28.1      
    
index.php   ,    
. 
     . 
      
 
 
 
output_fns.php 
 
 
 
 
create_database.sql SQL 
       
 ,    
. 
    HTML. 
,     
 .     
     
. 
    . 
SQL-     mlm    
 Web     
. 
       ,     
     . 
   
       : 
 Lists ():  ,   . 
 Subscribers ():     . 
 Sub_lists ( ):  ,    -
 (  --). 

 4       MySQL 
 Mail ():     . 
 Images ():      -
  ,     (.., ,  
HTML   ),   ,  -
      . 
SQL-,    ,    28.1. 
 28.1  SQL-    
create database 
use mlm; 
create table lists 
( 
listid auto increment not null primary key, 
not null, 
blurb 
create table subscribers 
( 
email char(lOO) not null primary key, 
not null, 
not 
password not 
admin tinyint not null 
#      
create table 
( 
email not null, 
listid int not null 
create table mail 
( 
mailid int not null primary key, 
email not null, 
subject not null, 
listid int not null, 
status not null, 
sent 
#  ,    
create table images 
( 
mailid int not null, 
path not null, 
not null 
grant select, insert, delete 
on 
to identified by 
insert into subscribers values 
'H', 

 28.      
,   SQL-  ,  
-u root -p < 
       root. (,   
    -   MySQL,  -
  ;       root  
   .)     ,   -
      . 
       , -
     . 
 lists     (email)    
(realname).       password   (admin), , 
    .     
   ,    .  
     HTML    . 
 sublists     (email)   subscribers 
     lists. 
 mail       , -
  .       
 ,    (email),    
(subject)  listid ,       . -
   HTML-     ,   
      .  ,   -
     :    (status), 
    (sent)   ,    
   (modified). 
,  images     , -
     HTML.      -
,          . -
      mailid,    ,  
path        
(mimetype), , image/gif. 
  SQL-   ,   -
     PHP-,    
   . 
 
  ,       .  
     index.php.      
 : 
 :  ,     
   . 
2     :     HTML-
. 
3.  :    .     -
,     
4.   . 

536  5.      MySQL 
       .   , 
    ,   . 28.1. 
      28.2. 
 28.2 index.php     
/********************************************************************** 
*  
ft********************************************************************/ 
include 
= 
//  ,  -   
//   
= '' 
//         
//   
{ 
= 
= 
{ 
.= . logged in" 
successfully as 
= 
} 
else 
{ 
.= . logged in" 
. 
= 
else 
{ 
.= we could not log you in with that 
address and 
} 
) 
{ 
} 
* 2:     
//       
{ 
//     
$buttons[0] = 
= 
= 
= 
= 
} 
else 

 28.     
  
= 
= 
= 
= 
= 
= ' 
= 
} 
else 
{ 
    
= 
= 
= 
) 
< 
//         
//   
-
} 
else 
{ 
 ,     
} 
//   ,  ,  
//     
echo 
*    
//     
switch ( ) 
{ 
case : 
< 
} 
case : 
< 
if 
= '' 
} 
case : 
case '': 
{ 
if 
} 
case : 

   5.       MySQL 
case : 
For , 
case : 
> \ 
    
switch ( $action ) 
case : 
, 
break; 
case : 
Lists", 
, 
case : 
$id) 
case ' : 
Lists", 
break; 
case '': 
case : 
Lists", 
, ' , ' 
case : 
sword_f 
break; 
case : 
if 
echo Password 
else 
echo your password could not be 

 28.     
break; 
//    
//   
{ 
( ) 
{ 
case : 
{ 
} 
case : 
{ 
display list email 
break; ~ 
case : 
{ 
if 
echo list 
, 
else 
echo could not be stored, please try 
. 
case ' : 
{ 
break; 
} 
: 
{ 
break; 
*  
      . 
        , -
     ,      -
.            . 
       ,  -
 ,       
   .     -
     ,       -
. 

540  5.      MySQL 
         -
.      : ,   , 
   , ,    -
 ,  ,    , -
  .        
       
          
   28.3. 
 28.3    user_auth_fns.php    , 
  ,        . _ 
// ,  
//      
{ 
global 
if ) 
return 
return false; 
} 
// ,  
//      
{ 
global 
if 
return true 
else 
return false; 
} 
{ 
return ( 
 ,  ,   ,    -
       
   . 
        HTML, 
      output 
      .    . 
28.2. 
 ,   store-mail,    -
 ,      
    .   ,   -
           , 
      . 
         , -
  . 28.2, .. ,   -
; ,   ; , 
 . 

 28.     
 28.2     
-   
log-in 
new-account 
show-all-lists 
show-archive 
information 
account-settings 
show-other-lists 
subscribe 
unsubscribe 
change-password 
store-change-
password 
store-list 
view-mail 
send 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
 
 
 
 
  
 
   
 
  
    
 
   
  
   
  
  
   
   
    
   
   
   
  ,  
    
  ,  
   
    
   
    
   
    
 
    
   
    
  
    
   
    
    
  
,   
,     
  
  

 5.      MySQL 
  
,   ,  ,   . 
-,   ,   ; -,   -
; -, .       . 
 . 28.4  ,     . 
         ,   -
         "  
"  "  ". 
   
     New Account (  ),  
  new-account.      
   index.php: 
case : 
{ 
 ,        ,  
 ,       ,   
. 28.5. 
      
output_fns.php.       ,      
      ,    
   .       
 ,        
.             -
 .       HTML-,    
  . 
 28.4 
   
  
  
,  
  
   
. 
 . .. 
j 

 28.     
 28.5 
   
   
  
  . 
 submit ()     store-account,  
   : 
: 
if 
= 
        .  
     28.4. 
 28.4  store_account()   mlm_fns.php    
,   ,   .     
//        
//     
function details) 
echo "All fields must be filled in. Try 
return false; 
else 
  
    
query = "update subscribers set = 
= 
where email = . details [email] . 

  5.      MySQL 
) 
return true 
else 
echo "could not store 
return 
else 
{ 
echo that email address is already registered 
echo will need to log in with that address to change 
return 
else //  
{ 
= "insert into subscribers 
values ' , 
if Si 
{ 
return 
} 
else 
{ 
echo "Could not store new 
return 
   ,     . 
  ,     ,    
    .    -
      ,     -
. 
        -
     .    
  ,      ,  
   . 
    ,   . 28.4,  
   Log In (),    -
        -
,     ,    -
 : 

 28.     
 28.4 () 
//       
//      
{ 
= 
{ 
.= logged in" 
. successfully as 
= 
}
else == 
{ 
$status .= logged in" 
= 
}
else 
{ 
$status .= we could not log you in with that 
email address and 
 ,        
 login()   user_auth_fns.php.     
  ,    ,    -
.      28.5. 
 28.5  login()      
     _ 
function $password) 
//      , 
//    
//   ,   
//      false 
{ 
//    
$conn 
if 
return 
= "select admin from subscribers 
where 
and password = 
   
= 
if 
return 
if 
return false; 
0, 0) 1) 
return 
else 
return 
18 216 

 5.       MySQL 
        
   false   .      -
  false   ,       -
  :     -
  ,      
        
 .     ,   false.  
  ,    1 (true)   
        
    ,    -
   ,    .    
 $admin_user,    ,  
   .        ,  
     .     
        
    28.6. 
 28.6  get_email   mlmjns.php    
      
function 
global 
global 
if 
return 
if 
return 
return 
      ' ,    
,   ,    . 
      . 28.6. 
 28.6 
  
,  
  
 . 
Log 
tfvt | ' 
J 

 28.     
,      ,   
   . 
   
,        : 
   ,    
          
      
    
    
       . 28.6.    
   . 
   
           
  .  . 28.6    : Show My Lists (   
),    ,     -
,  Show Other Lists (   ),    
,     . 
     . 28.4,  ,     
  Show All Lists (   ),     
    .      
 ,         ( 
, , 10    ).      -
 . 
    , ,  
show-other-lists  show-all-lists.  ,     -
  .     : 
: 
< 
Lists", 
} 
case : 
{ 
break; 
} 
case '': 
case : 
{ 
} 
 ,        
output_fns.php,         .  -

548  5.      MySQL 
        
     .    -
   . 28.7. 
! 
Show Other 
 28.7 
 
  
  
 ,  
   
. 
PHP 
Pyramid 
     Show Other Lists (   -
). 
    display_items(),     28.6 
 28.6  display_items()      
          
function $list, 
global 
echo width = cellspacing = 0 cellpadding = 0 
border = 
//    
$actions = + = + ($action3!= 
echo 
colspan = (l+$actions) $title 
//   
$items = 
== 0) 
echo 
<td colspan = = center>No Items to 
else 
//    
= 0; 
//    
// (    ) 
$bgcolor = 

 28.     
else 
$bgcolor = 
echo 
<td bgcolor = $bgcolor 
width = -
echo 
echo -
echo 
      
= 1; $j++) 
{ 
$var = 
echo bgcolor = $bgcolor width = 
 /   
//      
== 
$$var == 
else 
$$var, . 
echo 
echo 
} 
echo 
     ,       
    .     -
: 
  ,      ;   
,   . 28.7,     "Unsubscribed 
Lists" ("  "),      -
     "Show Other Lists". 
   ,       -
.       ,    
    .    (  )  -
     .  
 ,         
    .   : 
     ,  
   .     -
  ,      -
.          
      . 
     .   , -
   . ,  ,   . 
28.7,        PHP Tipsheet. 

550  5.      MySQL 
   .    , 
     ,  -
      -
 .       -
    View Mail (  
 )   "  ". 
          . 
,          
,     ,   . 
 . 28.7     : Information (), 
Show Archive ( )  Subscribe (). 
     Show All Lists       
  information, show-archive  subscribe.    
          -
    . 
    ,   Show   
-.  ,         
  ,        
  .  Show All Lists   
Show Other Lists   a Show My Lists  
     .    
   
      
   .      28.7. 
 28.7    mlm_fns.php   
        
   _ _ 
function 
{ 
$list = array () 
= "select 
email from lists left join 
on = 
and where email is NULL order listname"; 
if connect 
{ 
= 
if 
echo to get list 
= 
= 0; 
$i, 
mysql $i, 
return 
 ,        .  
     ,    . 

 28.     1 
        
 , ,   ,     
. 
    ,      
    ,     .  , 
      MySQL     
 LEFT JOIN. 
        
    
,   ,    ,   -
     . 
     
 Information (),   . 28.7,   
   : 
case : 
{ 
     . 28.8. 
        , 
            
   (     ). 
      28.8. 
 28.8 
 
  
  . 
tod, 
. Step Mai 1 
Information 
Pyramid Newsletter 
Company newsletter. Contains information relevant to Interested 
Number of 1 
Number , 

  5.       MySQL 
 28.8  display_information()     
      
{ 
return 
$info = 
{ 
echo of . 
echo of messages in . 
     Web   -
   :   load_list_info() -
     .     
,      ,      -
  HTML  .. 
    load_list_info().     -
        28.9. 
 28.9       
      _ 
function load_list 
{ 
return 
if 
return false; 
= "select listname, blurb from lists where listid = 
$result = 
{ 
echo "Cannot retrieve this 
return 
} 
= 
= "select from where listid = 
= 
if ($result) 
{ 
= 0, 0) 
} 
= "select from mail where listid = $listid 
and status = 
$result = 
if 
{ 
= 0, 0) 
} 
return 

 28.     
           -
       lists,    
       -
 mail. 
    
     ,  , 
   Show Archive,     , 
     .     
show-archive,      : 
case : 
{ 
For 
') 
break; 
} 
     display_items()    -
    ,    . -
         
     28.10. 
 28.10  get_archive()   mlm_fns.php    
        
 
function 
{ 
  
   
   ) 
$list = array () 
= 
= "select subject, listid from mail 
where listid = $listid and status = order 
if 
{ 
$result = 
{ 
echo to get list from database -
return 
} 
= 
= 0; $i++) 
{ 
$row = $i, 
$i, 
} 
} 
return 

  5.     MySQL 
  ,           
      ,    -
  ,     
    
   ,   . 28.7,    
 ,       . -
,      Show My Lists   - 
    ,      -
 Unsubscribe ( ). 
    subscribe ()  unsubscribe ( 
),  , ,    : 
case : 
{ 
subscribe , $id) 
} 
case : 
{ 
$id) 
break; 
} 
         -
      ,  
     . 
     
 28.11  subscribe()    mlm_fns.php   
         
function $listid) 
{ 
if 
return false; 
     , 
   
return 
if 
return 
= "insert into values 
$result = 
return 
} 
function $listid) 
{ 
return false; 
return 

 28.     555 
= "delete from where email = and listid = 
return 
    ,  -
;    . 
     
   Account Settings (   ) -
  account-settings.    : 
case : 
get_real 
 , -    -
     .      -
    ,      -
    .    ,   
     ,   store-account. 
  
   Change Password ( )   
change-password,      : 
case : 
 (   -
 ,       .     
. 28.9. 
 28.9 
 
  
  
 . 
Change Password 

3  5.     MySQL 
     Change Password     -
,   store-change-password.    : 
 : 
{ 
< 
echo Password 
} 
else 
{ 
echo your could not be 
> 
} 
 ,        
         
.      
     28.12. 
 28.12      
      _ 
//    
//    
//  true  false 
{ 
//    , 
//    true, 
//     false 
if 
{ 
{ 
if = 
return 
= "update subscribers 
set password = 
where email = 
$result = 
$ re 
} 
else 
echo Your passwords do not 
} 
else 
echo old password is 
return false; //    
        -
 .       ,  -
  ,   ,    ,    -
   . 

 28.     
  
     Log Out (  ),  
 log-out.        -
      : 
    ,    ,  
 .  ,       .. 
       - ,  
 : 
        -
   . 
   
 -    ,   
  ,   . 28.10. 
   Create List (   -
), Create Mail (   )  View Mail ( 
    ,     -
).     . 
 28.10 
  
  
   
 . 
logged In 

  5.      MySQL 
   
           
 Create List (  ),    create-list, 
   : 
case : 
{ 
  ,    
    .      
    HTML-,       
.     . 
     Save List (  ), 
  store-list,       index.php: 
case : 
echo list 
Lists", 
else 
echo could not stored, please try 
. "again 
break; 
 ,        
 ,       .  
    store_list().      -
 28.13. 
 28.11 
  Create List 
,  
   
  ( 
 ) 
  . 
Create List 
Contains to employees 
and other interested parties. 

 28.    
 28.13  strore_list()      
      
function 
{ 
echo "All must be filled in. Try 
false; 
) 
{ 
return false; 
//     -, 
//    ? 
{ 
return false; 
} 
= "select from where = 
$result = query 
0, 0) > 0) 
{ 
echo "Sorry, there is already a list with this 
return 
} 
= "insert into lists values (NULL, 
$result = 
return 
      ,     
:      ,    -
 ,      .   -
,     lists  . 
    
-       :   -
     . 
     Create Mail (  -
 ),    
case : 
< 
} 
  ,   . 28.12. 

560  5.      MySQL 
 
. 0 ....... ..... 17V 
 !. ..... | 
 28.12 
  Create Mail 
(  
 ) 
 
 
   
  
. 
Mail 
. 
,      ,   
        : HTML 
 ,       .    , 
        
  .     . 
 ,     ,    -
.         -
,     .      
      Subject ()   
 . 
       ,   -
      Browse ().   -
 ,     ,   HTML--
   (, ,        
).      ,   -
    ,   HTML.    
     . 
      ,  -
 ,          .  -
           
    . 
     28.14. 
 28.14  display_mail_form()   output_fns.php   
    
$listid=0) 
//      
global 
$list = 
$lists = 

 28.     
= 4 = 0 border = 0 width = 
<tr> 
<td bgcolor = 
List: 
<td bgcolor = 
<select name = list> 
<? 
= 0; $i++) 
{ 
value = 
if echo 
echo 
} 
?> 
</select> 
<tr> 
<td bgcolor = 
Subject: 
<td bgcolor 
<input type = text name = subject value 
size = 60 
</tr> 
<trXtd bgcolor = 
Text 
bgcolor = 
<input size = 
</tdX/tr> 
<trXtd bgcolor = 
HTML Version: 
</tdXtd bgcolor = 
<input size = 60> 
</tdX/tr> 
<trXtd bgcolor = colspan (optional) 
= 
= 0; 
echo bgcolor = ' ($i+l) 
echo bgcolor = 
echo ($i+2) ] ' = 60X/tdX/ 
} 
<trxtd colspan = 2 bgcolor = align = center> 
<input type = hidden name = value = 
<input type = hidden name = listid value = 
<? ?> 
</tr> 

  5.       MySQL 
 ,   ,   ,   
   ,      file,      
  ,      ,  -
   ,        -
,     . 
   PHP-    , -
   . 
,   ,    .  
  . 
    
,  ,         
.        28.15. 
 28.15 upload.php      ,   
 . 
//        
//   
//  -   ,  ,    
= 50000; 
include 
//      
{ 
echo do not to authorized to use this 
} 
//     
= 
= 
= 
= ,-
=  
= 
= 
= 
= 
-
//       
{ 
echo "Problem: You did not fill out the form fully. The images are the 
only optional fields. Each message needs a subject, text 
and an HTML 
() 
} 
if 
{ 
echo not connect to 
() 
exit; 

 28.     
//         
= "insert into mail values (NULL, 
NULL, 
= 
 MySQL    
= 
//  ,       
//   
//    
//     
exit; 
//    
$i = 0; 
while 
echo -
echo 
if ($userfile 
{ 
echo "Problem: zero length"; 
} 
if 
echo over 10000 
) 
//   
//     
//    
{ 
echo "Problem: is corrupt, or not a gif, jpeg or 
} 
//  0 ( )   1 html) 
//   
if($i=0) 
$destination = 
else if($i 1) 
-
else 

  4  5.      MySQL 
= 
= "insert into values 
$result 
  
/* 
if 
{ 
//     
"Something funny happening with not 
exit; 
, 
*/ 
//    4.02 
copy 
echo 
      28.15. 
,     ,    
     ,  -    . 
 ,        -
   ,       . 
          -
  .     ,   -
   . 
              
,     . 
      ,     
     .       
 .       .   
     -
       ,     -
 .           -
  
   ,       -
     . 
      ,    
        -
,     . ,   
upload.php.   . 28.13. 

 28.     565 
 28.13 
  
  
    
. 
I 
Upload 
I 
Uploading -
Uploading - bytes 
Uploading graph 
    
       -
  .        
  ,       
 . 
        ,    -
   View Mail ( ),     
   ,   .  View 
Mail   view-mail,    : 
{ 
break; 
 ,      display_items(),   
,    preview-html, preview-text  send. 
 ,   "Preview"     -
,         -
  .       28.6  28.15,  ,  
        
       -
    GET;    
  .       ,    
  HTML- .   
 HTML-     . 28.14. 

566  5.      MySQL 
 28.14 
 
 
  
HTML,  
. 
Press Release 
to MLM not as 
Pyramid Ltd 12 minion 
10% more the 
  
   Send ()    
 send,      : 
case : 
{ 
        
-  .  ,      HTML 
MIME Mail. 
      28.16. 
 28.16      , 
   
//        
//          
//  
function 
return false; 
= 
echo "Cannot load information for message 
return false; 
= 
= 
= 
= 
= 
= "select email from where = 

 28.     / 
$result = 
it 
{ 
echo 
return false; 
) 
else if 
{ 
echo "There is nobody subscribed to list 
return 
} 
= new 
//   
= 
$text = fread($fp, 
fclose 
//  HTML- 
= 
$fp = fopen "r") 
= fread($fp, 
fclose 
//   
= "select where = 
{ 
= 
{ 
echo to get image list 
return false; 
} 
= 
= 0; 
{ 
   
= $i, 0) 
= 
= 
//  
$i, 
//    mimemail 
//      
//   
HTML-  
  
"From: 
echo "Mail sent to 

568  5.      MySQL 
= "update status = where = 
{ 
= 
echo send again to send mail to whole 
echo 
) 
else 
{ 
    
= "select 
from subscribers 
where = $listid and 
= 
if 
return 
= 
if 
echo getting subscriber 
= 0; 
//    
= ) 
{ 
if 
HTML-    
else 
    
"From: 
= "update mail set status , sent = 
where mailid = 
( 
$ result = 
} 
echo total of were 
} 
else 
echo mail has already been 
     . 
      , 
      .    , -
      .    -
  ,       
 "STORED" (""). 
  send() ,     "STORED",  
   "TESTED" ("")    . -

 28.     
 "TESTED" ,        
 .   - "TESTED",     "SENT" 
(""),       . 
 ,         
:          . 
        : -
 ,     PHP-  HTML--
,      HTML MIME Mail.  
    ,     
 HTML MIME Mail.         ,  
,        . 
         : 
= new 
            
,     ,   : 
0) , 
$i, 
 ,     -
  ,   ,    
. 
 ,         HTML--
: 
$text) 
      : 
,    ,   .    
       ,   
  ,    send() HTML MIME Mail  -
  mail(),     MIME,  : 
HTML-   
else 
    
$text, "From: 
       
,       . 
  !      . 

  5.      MySQL 
  
      ,   -
    .  : 
     ,    
      .     -
           -
,     .      
         
. 
       , 
     . 
      ,  
      . 
        
 . 
      , -
  . ,     
 ,  .    -
      , 
        . 
  
      Web-,   -
    ,     
 . 

29 
 
Web- 
    
     Web-.  -
     ,  -
      
     . 
   Web-     .  
       
     ,   
 Web-    
    .  -
   ,     
    ,     
      .   
    . 
  Web-,  blah-blah  -
    : 
    ,  -
 
        
      
      
    , .. -
,       -
. 
 
     -
 .   -   
        -
,   .      
        
 

 /  5.      MySQL 
,       ,  
         -
. ..,   ,       -
 (     ),      . 
  ,    , 
    ,      
       . -
      ,   
       . 
          
    .      
. 
  
  ,         
   . 
         , 
    ,     
  . 
         . 
 1   1 
 1   1 
 1   3 
 29.1          , 
       . 

 29.  Web- 7 
   ,    ,    
,     .      .   , 
      ,  .. 
    ,          
 .     .  ,  
    , ,      -
    .      
  ( )   (   ). (    
       ,    
        .) 
   ,      : 
1.         ;  -
      MySQL. 
2.      . 
      MySQL,     
  . 
      ,   
. 
   ,   ,   -
    PHP-     
       . 
    .   ,     
       ,   
 tree_node,  ..       - 
  ,     .   -
  ,      . 
   : ,    ,  
    .       
    .   ,   -
     . 
            
  . 
    ,      
   ,     . 
          
. (     5.) 
      ,     
         
.           
   . 
  
  ,      , , -
    ,     .  -
   ,   ,      . 

574  5.     MySQL 
     . 
     ,     
     .       , -
       ,   
  . (     .) 
            
    . 
            
    ,      . 
       . 29.2. 
 29.2 
  blah-
blah   
 . 
  
  
(  
) 
 
  
 
       . 29.1 
  Web- 
   
  ,    
    .   
    ,   
. 
,     . 
 ,    new_post.php. 
      
  . 
    
    . 
     
 (     
  ),    
. 
  . 
   . 
     . 
   HTML. 
 SQL    
   . 
view_post.php 
 
 
 
 
php  
 
 
 
SQL 
   . 

 29.  Web- 575 
   
   ,     , -
  : ,     ;   
;  . ,    .   -
    ,  
          . 
            . 
,      ,     -
      .    
       ,    -
 , .. ,    . 
         : 
 postid:     
 parent: postid   
 poster:    
 title:    
 posted:       
 message:   
          . 
  ,    - ,  -
     -  ,    -
  .        
 .     ,     
.       ,  ,   
  .    children        
   1,     ,  0,   . 
    .      
.     ,  , 
         -
     .     -
 ,         -
 .           
,      .    -
  ,      . 
 ,         -
. , Oracle    .  -
 MySQL,        , -
          , 
  -        . 
    .      -
      .    ,     
  text MySQL.         -
  .      -
    ,     -
 .        ,   
  ,      . 

576  5.       MySQL 
MySQL       ,  -
   .     -
    ,    ,  
      .      
       ,    ,   
   ,     .   
  ,    ,  ,   -
,         -
. 
 ,     area   ,   -
       .    
    ,       -
. 
SQL-,        , -
   
 29.1 create_database.sql      
create database discussion; 
use discussion; 
create table header 
( 
parent int not null, 
poster not null, 
title not null, 
children int default 0 not 
area int default 1 not null, 
posted not null, 
postid int unsigned not null primary key 
create table body 
( 
postid int unsigned not null primary key, 
message text 
grant select, insert, update, delete 
on 
to identified by 
     ,     -
 MySQL  : 
-u root -p < 
       root. ,  -
   ,    ,  -  
. 
 ,         ,  
 . 29.3. 
 ,         postid , 
    .     ,   -
 . 

 29.  Web- 
 29.3 
   
   
  
  
      
postid: 1 
postid:2 
postid: 3 
postid: 4 
postid: 5 
postid: 0 
postid: 1 
postid: 1 
postid: 2 
postid: 2 
postid: 1 
postid: 2 I postid: 3 I 
| postid: 4 postid: 5 I 
   ,   postid 1    .  
       .      
       0 (). 
   
          -
      .       
        -
       -
     . 
    ,     .  
        . 
  ,   ,   
. 29.4. 
 ,    ,  .     
  ;          . 
 ,    .     , 
         -
 . 
   ,    .     
   .  ,       -
.      ,     . 
         . 29.5. 
 29.4 
  
  
  "" 
. 
19 216 

 /   5.       MySQL 
 ,           
 .       .  -
  ,      ,    -
. 
  , ,        -
 .  ,      .    
  ,      ,  
   . 
   , Expand ()  Collapse (),  -
      .    -
 Expand   . 29.6. 
 29.5 
  
   
"persistence" 
(" 
1 . 1 . 1  
: , ' 
I Discussion Posts 
PHP -
-" . 
-
' 
Re: flersistenqe? --
. 
new article -
 29.6 
   
 
1 4 ' ' ' 
1, 
Posts 
Expand 
PHP 39 
Re: 
PHP 
- Laura -
Re: 
- 05:07 

 29.  Web- 
    . 29.5  29.6,  ,   -
        index.php.  . 29.5 
Internet-   : 
i      "    
6".  #      HTML,    
     . 
   Internet-   
   Expand   expand   
   
  ,   ,   index.php, -
   29.2. 
 29.2 index.php        
  
<? 
include 
// ,    
{ 
$expanded = () 
> 
//    expand 
//  expand  
// postid     
if 
{ 
== 
else 
= true 
> 
// ,    collapse 
//  collapse   
// postid        
{ 
else 
} 
//    
ooter 

  U  5.       MySQL 
        : 
     .   
    ,     
 .     ,  
,        . 
   ,     -
. 
   ,    . 
          Expand  Collapse  
         
        
 ,         -
. 
         -
  ,      . 
   ,       
       , 
   
{ 
== 
else 
= 
} 
    Expand  expand_all()    
 ,  ,   (   
.) 
   ,  postid    -
          
 expand_all()    29.3. 
 29.3  expand_all()   discussion_fns.php    
       _ 
expand 
< 
//       
//     
$conn = 
= "select postid from header where children = 1"; 
$result = 
$num = 
= 0; $i++) 
{ 
$i, 
        ,   
   : 
select postid from header where children = 1 

 29.  Web- 5  1 
         -
       .     
     ,    
     . 
   ,   : 
{ 
else 
} 
    ,   .   
      ,    -
  . 
       ,  
,     ,    .   -
    
      . 
  
   display_tree(),    29.4. 
 29.4  display_tree()      
     _ 
$row = 0, $start = 0) 
{ 
//     
global 
echo width = 
// ,      
= true; 
else 
= false; 
//    
$tree = new treenode 1, true, -1, $expanded, 
//    
echo 
         .  -
     ,       
  ,    . , 
        -
 . ,    ,    
      . 

   5.      MySQL 
 ,  ,      -
.     ,      -
.     ,      , 
    0, ..     ,  
  .      -
  false     . 
    0,      -
,   ,    true  -
      . (    -
 
  ,       -
    .      -
,          , -
    .     ,   
        . 
  treenode 
  treenode    29.5. (      -
  6,  ,   .) 
 29.5  treenode      
 
<? 
//    
//      
class treenode 
{ 
//      
//  ,    , 
//     
var 
var 
var 
var 
var 
var 
var 
function $title, $poster, $posted, 
$expand, $depth, $expanded, 
{ 
//   -, ,   
// ,       
= 
= 
= 
= 
$this->m_children 
= 
= 
// ,    , 
//  ,      
//      
&& $children) 
{ 
$conn = () 

 29.  Web- 5  3 
= from header where parent 
order by posted"; 
$result = 
for $row = 
{ 
if ] == true) 
$expand = 
else 
$expand = false; 
new 
$expand, 
$expanded, 
= false) 
{ 
//      
//  
//  
//        
// ,       
//      
// true. 
//         
//   
//      
// 
//     
echo bgcolor = 
if ($row%2) 
echo 
else 
//     
= 0; $i++) 
{ 
echo src = ' height = 22 
width = 22 alt = ' ' = 
> 
//     
if ( SS $this->m_children &S 
//      
//    
{ 
//      
//   
echo href = ' 
src = valign bottom 
height = 22 width = 22 
alt = border = 

584  5.      MySQL 
else 
{ 
//      
echo href = ' . 
arc = 
height = 22 width = 22 
alt = border = 
> 
else 
{ 
//         
//    
echo src = ' images/spacer height = 22 
width = 22 
alt = = 
} 
echo <a name = href = 
-
-
echo 
//     
//    
} 
//   display      
//       
//       
= 
= 0; 
$row = 
} 
return 
   ,       -
. 
        
        .   -
  -: 
var 
var 
var 
var 
var 
var 
var 
 ,  treenode    .   -
     ,       
     ,   
        -
,           
. 

 29.  Web-  
        , 
   -     -
      ,    -
- . 
       
header   . 
    $m_depth.  
       .  $m_depth 
             
  . 
     : 
function $title, $poster, $posted, 
$expand, $depth, $sublist) 
{ 
//  ,   
//      
= 
= 
= 
= 
= 
= 
   treenode      
   ,       .  -
   : 
$tree = new treenode ($start, '', 1, true, 
$expanded, 
    ,    .  
        ,  
    .    -
        .    
           . -
     . 
  ,       -
    .      -
   .      ,    
-  ,     : 
$children) 
{ 
$conn = 
            
: 
= "select * from header where parent = 
$postid order 
$result = 
     treenode,  
  ,   treenode: 

586  5.      MySQL 
for = 
{ 
] == 
$expand = true 
else 
$expand = 
new 
$expanded, 
} 
     treenode      
 ,     .     
.      treenode,  -
 postid       1    -
   . 
  treenode        
    ,          
   . 
     ,     -
  treenode (   
    ,     -
  : 
        .   
     .   ,   
       ,     -
. 
    ,  .    
          
(   ): 
//   
echo bgcolor = 
echo 
else 
echo 
 - $m_depth     , 
    .   ,   -
 ,    ,    .   -
 : 
//    
= 0; $i++) 
< 
echo arc = ' images/spacer height = 22 
width = 22 alt = ' valign = 

 29.   / 
      ,    -
 ,    : 
//    
if ( && $this->m_children && 
//  ,     
//    
{ 
//         
echo href = ' . 
src = valign = bottom 
height = 22 = 22 alt = Collapse border = 
> 
else SS $this->m children) 
{ 
//        
echo href = ' 
src = 
height = 22 width = 22 alt = border = 
} 
else 
{ 
//         
//      
echo src = images/spacer height = 22 width = 22 
alt = = 
} 
      : 
echo <a name = Xa href = 
-
-
echo 
    : 
//     
//     
   ,      
treenode,    : 
//   display     
//        
//       
= 
= 0; 
$row = 
} 
return 
     ,     -
   ,    .      
,          .   -
  . 

    5.       MySQL 
       .   . -
,     ,  ,    
,     . 
   
        .  
     ,      -
  postid,  ,   .  
,   ,   . 29.7. 
| i 
 29.7 
   
   
. 
How make a to 
Archer 
Re: --
Re: - Luke -
' 
    ,      . 
 ,           -
       .     -
 
    viewjost.php,    29.6. 
 29.6 view_post.php        
//    
include 
//    
$post = 
  
//    - ,   
//     
echo ; 

 29.  
0, 
} 
          -
: display_post()  
     .    
   29.7. 
 29.7  get_post()   -   
     _ 
function 
{ 
       
return false; 
= 
   
= "select * from header where postid = 
$result = 
return false; 
$post = 
       
= "select * from body where postid = 
$result2 = 
$body = 
{ 
= 
} 
} 
return 
  postid,     ,  
        ,     -
   . 
        -
      ,   
  HTML-,       -
. 
 ,  ,   -   
 ,    display_tree()      
  ..    -    . 
   
  ,      .  
    : -,    New Post ( 

590  5.      MySQL 
)    ,  -,    Reply 
()   
            
.  . 29.8  ,   new  
   Reply. 
 29.8 
   
, 
 
  
. 
can explain to how I can use gd to 
dynamically create 
-,   Internet-: 
,    parent,   postid -
   .    Reply    
New Post,  Internet-    
-,  ,         
         
   . 
-,        -
    
  ,    .     
29.8. 
 29.8 new_post.php        
      
include 
$area = 
if (!$error) 
if $parent) 
$parent = 

 29.  Web- 
$title = Post"; 
} 
{ 
//   
= 
//   
"Re: false ) 
= "Re: 
// , -   
= , 
//       
= 
> 
) 
display $area, $title, $message, 
if 
echo "Your message was not stored. Make sure you have filled in 
all and try 
() 
       ,   
    - .   ,   -
      . 
     ),   -
    : 
//    
$title = 
//   Re: 
"Re: == false ) 
$title * "Re: 
//   -    
= 
//       
$message = 
      
 discussion_fns.php.  , ,   29.9, 29.10 
 29.11. 
 29.9  get_post_title()    
        
function 
{ 
//  
return 
$conn = 
//     
= "select title from header where postid = 

  5.      MySQL 
$result = 
return 
return 0, 0) 
 29.10  get_post_message()   
       
function 
{ 
//      
return 
$conn = 
= "select message where postid = 
$result = 
{ 
return 
   , ,       . 
 29.11  add_quoting    
         
function $pattern = 
//      
//    
return 
   ,    
   ,     >. 
           Post (-
),    , -
  ,   . 29.9. 
        Re: using gd?  Laura  
09/26/2000.         index.php. 
        
 29.12        
<? 
include 
= 
{ 
include 
} 
else 
{ 
$error = 
include 

 29.  
 29.9 
   
  . 
1 
New I 
3 PHP --
: ..' ': 
Re: --
-- 07 
te--01- | 
- big coder-
 ,   .       
      .  -
  ,     .  -
        -
 . 
    29.13. 
 29.13  store_new_post()   discussion_fns.php  
          
function 
//       
= 
// ,       
return false; 
$post = 
//     
= "select postid from header where postid = 
= 
return 
// ,      
= "select from header, body where 
= and 
= and 
= and 

594  5.       MySQL 
= and 
= ]. and 
= 
$result = 
if (!$result) 
return 
return 0, 
= into header values 
0, 
, 
NULL 
$result = 
if 
return 
//     
//    
"update header set children = 1 where postid 
$result = 
if 
return false; 
    
//      
//    , . 
= "select from header left 
join body on = 
where parent = 
and poster = 
and title = 
and is 
$result = mysql 
if (!$result) 
return 
$id = 0, 0) 
= "insert into body values ($id, 
$result = mysql 
if (!$result) 
return 
return 
} 

 29.  Web- 
  ,    .     ,  
            -
         ,  
     . 
       Web-. 
  
      : 
           , 
         , 
 ,       -
   . 
          
     . 
      ,   -
     . 
    -     -
. 
        . 
   
    . 
  Web-      
.          , 
        . -
   Phorum  ,     
            . 
       : 
     phpslash.    , -
     Slashdot.    -
    PHP-.     : 
  
  30   PDF-   -
,      .   
     ,     
. 

30 
 
  
 
(PDF) 
       
    -
 ,      -
 .     -
      
   ,  
 ,   . 
 ,      -
,     
     -
  . 
 : 
    PHP-,  -
       -
      
(Rich Text Format, RTF). 
       
     
(Portable Document Format, PDF). 
   PHP-  PDFlib  -
  PDF-. 
 
     
,    .   -
       -

 30.      PDF

 7 
   ,    . 


    ,        
.           
 . 

         , 
   .         
 : 

1.    . 
2.         ,   
   . 
3.    . 
4.     . 
5.   . 
6.     . 
7.      . 
8.      . 
9.         . 
10.        . 
  ,      , 
  ,       
, ,    . 

   

   ,     .  
   , ASCII-, HTML,  
Microsoft Word  -   , RTF, PostScript  PDF. 
   ,      
  . 

  

       .  
    .      
 ,  ,     .    
      ,   
    . 

        , 
  5-  6-.       .   
        ,    
 . 

             
   ,      ,  
.        . 


   5.      MySQL 
    ASCII      -
.      .  -
    ,     . 
         -
   . 
,    ASCII-,   -
    .       -
 .           -
 .       
  .      
    . 
HTML 
      Web  HTML. 
Hypertext Markup Language (  )   
 . , ,   ,      -
,     ,  ,   
(  )      .  
  ,       ,   
      . 
  HTML-    : -
       ,  -
 ;         -
 ;   .  ,  HTML- 
     ,     
      . 
   
 ,    ,   
      .    -
 Internet        
  .   ,     , 
  Microsoft Word   .   
     Word,    ,   -
    . 
 Windows,   Word,    -
   Word  
    Microsoft Word   .  
   Word     . 
         ,  -
      .  ,  
     ,  Word  -
  . 
 ,    Word   ,    
     .  ,   

 30.      PDF 
     .  ,  -
 ,          
 . 
   
  ,  RTF-,   -
,    Word,    .  --
         
 .   -    ,  
   . -, -   -
,         -
 . 
RTF     Microsoft Word.     
         . 
     HTML-.     
       ,    -
,      . 
   .       
    
   RTF-    Save As RTF (-
  RTF)    .  RTF- -
  ,    ,   -
  . 
       , -
        ,  -
    Word.     ,  , 
  RTF-     Word    -
 ,      .   
   RTF-   . ,  , 
      ,    -
      . 
     ,    RTF--
     ,   -  -
 ;        
    ;     -
  ;       ;   
     . 
        -
,       .   , RTF-
         ,  -
       .   
    . 
RTF-       , -
            . 

 5.      MySQL 
PostScript 
PostScript,   Adobe,     
.        -
,         
.  ,   ,     -
    ,     .  
   .  ,   ,  
 ,     Web-. 
pt-     , , -
,     . PostScri pt-   -
  ,      PostScript.   
       . 
PostScript-         -
  .        -
       . 
  PostScript      
 : 
      . 
   ,     -
  . 
  UNIX    PostScript-,  -
 Windows,  ,     ,  
    PostScript.  -
     .    ,  
        
. 
   Ghostscript    : 
    : 
     PostScript   -
    ,    
   . 
  
 ,  ,    PostScript,  
  .    
(Portable Document Format, PDF),    Adobe,  
  ,       -
          
  . 
 ,   Adobe, PDF   " 
 -       . PDF 
 Adobe    ,    , 
        -

 30.      PDF 1 
    ,   . PDF- 
    , ,   -
  ,  ,   ,  -
  Adobe Acrobat Reader". 
  PDF    : 
     Web-    . 
   , PDF     -
. 
PDF-  ,     
  ,     .    -
      .    -
          
 .       -
. 
 PDF   ,      PDF--
  . 
  PDF-   ,  Adobe -
   Acrobat Reader  Windows, UNIX  Macintosh.  -
       .pdf ,  ,    
  . 
PDF-     , -
   ,   ,     
 .       -
  PDF-. 
  
  ,      
  (   )  , -
  .        
 :    PDF-    -
 RTF-. 
    ,     
 . 
    
    ,    
          
 ,      
     ,     -
      . 
         
,     Web.     
   . 
        
 .   HTML-    ,  
PHP-    .    ,    1. 

  5.      MySQL 
    
  RTF-  PDF-     
  Web-  ,      
 .   PHP-  PDF-, 
PDF    PHP-. (   
   .) 
     RTF- 
  RTF-       
 .      Microsoft Word.  
      CD-ROM     -
. 
     ,     
     Word,     
     . 
     PDF- 
 PDF-  .     -
 Adobe Acrobat.     PDF-  -
  .        
   . 
    Microsoft Word.   , -
    Acrobat  Adobe Distiller.   Distiller   
 ,    .    -
   ASCII,     .     -
    ,   . 
     Acrobat     
     Internet,     -
 . 
    PDF-   -
 ,     ,  PostScript-  
PDF-.     ,    . -
        ,   
   .   -
     
,     PDF-  ,   
 PostScript-.  ,    UNIX   
 a2ps  
    Windows PostScript-  ,    -
  Adobe Distiller,       -
.     PostScript. ,   
 Apple LaserWriter IINT.   PostScript  ,   
    Adobe: 

 30.      PDF 03 
  PostScript-      
 Print to File (  ),       
Print (). 
   Windows-     
      , 
   .ps.         
GSview     PostScript-    PDF-
    ps2pdf. 
  ,      PostScript- -
 .  ,    PostScript- -
           -
    . 
       PDF-,  -
      ,  -
 Adobe.        $9,99   
            
 PDF-.        ,  
    ,     . -
 PDF-        .  -
    . 
      
 ,    ,       
 . 
,     ps2pdf    -
  Net Distiller: 
    PDF-   
  PDF-    .   -
 ,     .    
  ,          -
. 
PHP-   PDFlib,   : 
  , ClibPDF,   : 
   .   API    
PDF-.     PDFlib, ,  
 ,      . 
 ,          -
     .    -
  ,     ,   -
      . 

604  5.      MySQL 
,     PDFlib  , ,   
     pdf  ,   -
 PDFlib,       . 
  PDFlib      TIFF,  
   
  JPEG,    
  UNIX      -
     configure  make.    -
     
  Windows     PDFlib   
      ,   
Web.   ,      ,  -
 Windows         
       
  
  ,       .  
  . ,     ,  ,  -
      : 
    RTF-   . 
    PDF-   . 
    PDF-     -
   PDFlib. 
 30.1 
  
  
   
  
. 
 
 
 
 
  
 
 
 
RTF- 
  
 
 
RTF- 
 
 
 
  

 30.      PDF 605 
  ,     ,  
  . 
 30.1 ,    
 
index.html 
 
HTML- HTML-,    
      
   RTF-   
   PDF-   
 
 
 
 
RTF- 
PDF- 
   PDF-   
  PDFlib 
  ,   
   PDFlib 
   RTF- 
   PDF- 
   . 
  
 index.html  .    HTML-,  
   ,     .  ,   -
         .   
     ,     -
  HTML-  . 
 name   .     , 
   ,   , .  -
   ,    . 
      
 30.1 index.html  HTML-,    _ 
align = center> 
src = alt = 
Certification 
src = alt = 
too can earn your highly respected PHP certification 
from the world famous Fictional Institute of PHP 
answer the questions below: 
action = method = post> 
<p>Your Name <input type = text name = 
does the PHP statement echo do? 
<liXinput type = radio name = value = 1> 
Outputs strings. 
<liXinput type = radio name = ql value 2> 
Adds two numbers together. 
<lixinput type = radio name = ql value = 3> 

606  5.       MySQL 
Creates a magical elf to finish writing your code. 
PHP function do? 
<lixinput radio name = q2 value = 1> 
Calculates a cosine in radians. 
<liXinput type = radio name q2 value 2> 
a tangent in 
<liXinput type radio q2 value 3> 
It is not a PHP function it is a lettuce. 
does the PHP function mail  do? 
<lixinput type radio name = q3 value = 1> 
Sends a mail 
<liXinput type = radio name = q3 value = 2> 
for new mail. 
<liXinput radio name = q3 value * 3> 
Toggles PHP between male and female mode. 
<p align = centerXinput type = image src 
border = 0> 
</body> 
    Web-   . 30.2. 
 
        index.html, 
       .     
score.php,      30.2. 
 30.2 
 index.html 
  
  
 . 
Certification 
PHP from 
PHP 
PHP echo da? 
1. 
I.  
3. 
3.  
 PHP fcmile mode 

 30.      PDF 7 
 30.2 score.php       
<? 
//      
{ 
echo align = = alt = '> 
= alt ' 
echo need to fill in your and answer all questions"; 
} 
else 
{ 
//       
= 
if == 1) //     1 
== 1) //   q2  1 
== 1) //    q3  1 
//     
$score = / 3 * 100; 
< 
{ 
/I   
echo align = centerXimg src = ' alt = ' > 
src alt = ' 
echo need to score at 50% to pass the exam" 
} 
else 
{ 
//     
//     
$score = 
echo align = centerXimg src = alt = ' '> 
Congratulations 
src = alt = ' 
echo done $name, with a score of $score%, 
you have passed the exam. 
//    , 
//   
echo click here to your certificate as 
a Microsoft Word (RTF) file. 
echo action = 'rtf.php' method 
echo 
<input type = image src = border = 0> 
echo type = hidden name = score value = 
echo type = hidden name = name value = 
echo 
echo click here to download your certificate as 
a Portable Document Format (PDF) file. 
echo action = method = 
echo 
<input type = image src = border = 0> 
echo type hidden name = score value = 

  5.       MySQL 
echo type = hidden name = name value = 
echo 
echo click here to download your certificate as 
a Portable Document Format (PDF) file generated with 
echo action = method = 
echo 
<input type = image src = border = 0> 
echo type = hidden name = score value = 
echo type = hidden name = name value = 
echo 
    ,       
      . 
     ,     
.       . 30.3. 
V 
' ' . 
 30.3 
 
 
,  
 , 
 
 
  
 . 
Congratulations 
Luke a of the 
click to your 83 a Word file. 
Please your certificate as a Document Format (PDF) file. 
click to download a (PDF) 
      .    RTF-
     PDF-.   , -
     . 
 
       RTF-,  ASCII-
      ,        
  . 
    RTF-: 
Times New 
\fO\fs28 
\fl\fs20 This is an rtf \par 

 30.      PDF 609 
    ,   : 
        Times New Roman,   -
    .     Heading,  
 fo (Arial)  28 (14 ).   -
  .     This is an document,  
 (Times New Roman)  20 (10 ). 
       ,   
   ,      -
  ,    .  ,   
 ,       ,  
        .  -
       . 
 ,    . 30.4,   , 
  . 
   ,  NAME   
   .       . 
   ,      -
.   ,       -
 .    ,   -
    ,   ,    . 
     NAME, Name, score 
  ,    NAME,  Name, -
         . 
,   ,     .  
        30.3. 
 30.4 
  
,   
   
. 
9  9  --
PHP Certification 
  -
| 
ha* they an by a exam 
of three multiple choice questions. 
Name obtained a 
The test t and by the 
ttofuJInrtltut* 
n 
20 216 

  5.      MySQL 
 30.3 rtf.php -     
 RTF- _ ___________ 
<? 
//     
II ) 
{ 
echo page was called 
} 
else 
{ 
 ,   
 
inline, 
$date = "F d, ) 
//   
= 
$fp = ( $filename, ) 
//     
$output = $fp, ) ) 
fclose ( $fp ) 
//     
$output = str_replace( ( ) , ) 
= str_replace( ) 
= str_replace( $score, ) 
= , 
//      
 cho$ 
        ,  
       ,     -
 . 
     RTF-,   HTML-,  -
     . ,    -
          
   Save As... ( ),      
RTF-. 
     -
   PHP-  : 
application/msword" 
"Content-Disposition: inline, 
   ,     Microsoft Word 
(      RTF-  -
,      ). 
       , 
            -
   ,      . 

 30.      PDF 
    ,     RTF- -
      str_replace()   -
  ,     .  
Soutput 
     Name   
          -
.        . 30.5. 
 30.5 
 
  
   RTF-
. 
PHP Certification 
This is to that 
LUKE WELLING 
has are by 
of three choice 
Luke a score rf 
The test was the 
November 
    .   str_replace()  
 ,   ,    , ,  -
  .       -
          -
   . ,       
. RTF-     "  ". 
 PDF-   
  PDF-       
.     ,    PDF-  -
      . ,   
   ,  ,    -
  : 
-13 -10 (>) -6 (> 
-9 0 () -18 
<) -11 (<) 1 <sc) -17 () -6 () -6 (>) -11 (> 
1 () -12 () 0 (/d) -6 -19 (/) 1 () -13 () -13 
   ,  ,     RTF,    -
  . 
      . 

612  5.       MySQL 
          -
.         ,  
     ,     -
   ,      . -
       PDF-    
     .    ,   
     ,     , 
, ,        -
     . 
   ,    .  -
 Adobe Acrobat   PDF-,  HTML-  -
  .    PHP-   
   (Forms Data Format    ),  -
   ,   .  , -
  PHP-  ,   -
 ;     ;  
      .    
         -
     Acrobat Reader   -
  . 
     ,     . --
, ,      Acrobat. -,   
,   ,      .   
  ,   ,    ,    -
.     PDF-   ,  -
       . FDF-   
    . ,   , , 
 ,     . 
       Adobe: 
     ,    
  FDF    : 
     PDF-   . 
  PDF-      ,  ,  
      ,   
  , ,      -
 .    pdf_replace()    
         -
  . 
   ,       PDF-
    RTF-.      30.4. 

 30.      PDF 
 30.4      
PDF-    _ 
<? 
180 //      
function $pattern, $string ) 
{ 
= $pattern 
= ' 
for ( $i = 0; $i++ ) 
{ 
$regexp .= 
if ($i<$len-l) 
$regexp .= 
} 
return ereg_replace ( $regexp, $string ) 
> 
{ 
page was called 
} 
else 
{ 
//   
//  
$date = date "F d, ) 
//    
= 
$fp ( 
//    
= fread( $fp, ( } 
( $fp ) 
//    
$output = pdf_replace( strtoupper( ), $output ) 
$output = pdf_replace( $output ) 
$output = pdf ( $score, $output ) 
$output = $date, $output 
//     
echo 
     PDF-. , 
  . 30.6,      ,  -
     .  , PDF-, -
  . 30.6,    ,  RTF-,   . 
30.5 
        ,   
 - ,    . 
    ,   
     

  5.       MySQL 
 30.6 
 
  
   PDF-
. 
PHP Certification 
This to that: 
LUKE WELLING 
a exam 
rftnlrt* 
I WHS 
rtf 
        -
         , ,   
  .          
 .         . 
 PDF-   
  PDFlib     PDF--
  Web.  ,     ,   -
,   ,       
 .     , C++, Java, Perl, 
Python,  ActiveX/. 
,        PDFlib  .  -
      PDFlib.  Web- PDFlib , 
 "   ,   ,    ", 
       . 
, ,        ,  
( )  ,   ,    . -
    ,       
 API     ,     
   ,      PDFlib, 
      PDFlib. 
 Hello  PDFlib 
       PDFlib,   -
       Hello World, -
   30.5. 

 30.      PDF 
 30.5    Hello World,  PDFlib  
  
//   
= "w") 
echo "Error: could not create the PDF file"; 
exit; 
//  
$pdf 
"Creator", 
"Author", "Luke Helling and Laura 
"Title", "Hello World 
//    US letter   11" x 8.5" 
//   72    
8.5*72, 
"Page 
24, 
50, 
//  
//   
pdf 
//    
echo "download the pdf <a href = 
  ,       
 ,  : 
Fatal error: Call to undefined function: in 
on line 6 
 ,   PDFlib     . 
  ,       -
      PDFlib.     -
          -
 PDFlib     . 
           
   . 
  ,   
$fp = 
    .  ,      -
        ,    -
  ,           
 Web-. 

616  5.      MySQL 
 
$pdf = 
 PDF-,     .   
  pdf_open()  ,       -
     .      
        
      PDF. 
     
, ,  , ,      -
 ,  . 
        ,  -
  .  ,      -
 . 
Welling and Laura 
"Hello World 
PDF-    .    ,  
    ,   
   .   
     ,         
,     . 
   ,         
 . ,   4  ,  
 595  842 ,    U.S. letter  612  792 -
.  ,   
8.5*72, 
   ,     U.S. letter. 
PDF-     .     -
   PDF,     .  
    .    -
      Acrobat Reader,   -
   . 
 
  ,   Page    
  . 
          -
,       .   ,  
    PDF-,   .  
14  : 
 Courier 
 
 Courier-Oblique 
 Courier-BoldOblique 

 30,      PDF  
 Helvetica 
 Helvetica-Bold 
 Helvetica-Oblique 
 Helvetica-BoldOblique 
 
 Times-Bold 
 
 
 Symbol 
 
      ,     ,   
         -
    . ,     -
    : 
24, 
    .      
host.      winansi, builtin, macroman, 
ebcdic  host.   : 
 winansi        ISO 8859-1  -
  ,   Microsoft,   -
  . 
 macroman   Mac Roman.  ,   -
   Macintosh. 
 ebcdic   EBCDIC,    AS/400  IBM. 
 builtin   ,   .   
   ,    . 
 host    macroman   Mac, ebcdic  , -
  EBCDIC,  winansi    . 
     ,     -
. 
PDF-    HTML-     -
.             -
   .      .   
,     PDF  .  -
 (,  [0,     . 
     612  792 ,   (50, 700) 
          -
          .    
  ,   
50, 

 1   5.      MySQL 
, ,   ,      
.          -
   
 
"Hello, 
    "Hello, World!" 
           
,      "(says 
          . 
         -
 
    PDF-      -
        . 
 
($fp) 
   Hello World.     
. 
echo "download the pdf <a = 
        ,    
PDFlib,      . 
,     ,     
,    .     -
        .   
PDFlib    . 
    PDFlib 
  PDFlib,     .   
   ,   ,  -
           
   ,     -
,  Microsoft Word. 
      ,   ,     
  ,       . 
        30.6. 
 30.6 pdflib.php      PDFlib 
<? 
{ 
echo page was called 
} 
else 

 30.      PDF  
,   
 
header( 
$date = d, 
//   
$pdf = pdf_open 
//      
//  letter   11"  8.5" 
//  72  
$width = 
$height = 
$width, $height) 
//   
$inset = 20; //      
$border = //    
$inner = 2; //    
  
$inset-$inner, 
$inset-$inner, 
   $border  
  
 
48, 
$startx = ($width - "PHP 
"PHP $startx, 
26, 
= 
"This is to certify $startx, 
$startx+90, 
20, 
"has demonstrated that they are certifiable 
"by passing a rigorous exam", $startx, 
"consisting of three multiple choice 
$startx, 
obtained a score of 
$startx, 

620  5.       MySQL 
test was set and overseen by the 
$startx, 
Institute of PHP 
$startx, 
"on 
"Authorised 
//   
$signature = "tiff", 
200, 
ill 0, 0, blue 
0, 0, // black 
//  1 
pdf 610, 
646, 
666, 
//  1 
pdf 630, 
610, 
632, 
646, 
666, 
//   2 
660, 
680, 
695, 
716, 
696, 
//   2 
660, 
680, 
695, 
716, 
696, 
.8, 0, 
175, 10, $pdf, true) 
175, 32, 10, $pdf, 

 30.      PDF 
function $centery, $points, $radius, 
$point_size, $pdf, $filled) 
= 
($i = 0; $i++ ) 
$angle= ($i*2*pi / 
if 
$x = + 
$y = + 
else 
$x = 
$y = 
if ($i=0) 
$x, $y) 
else 
else 
$x, $y) 
($filled) 
pdf 
      . 30.7.  ,   
    ,   ,    , 
    .    ,     
  ,        -
. 
 30.7 
 
  
  
  

622  5.      MySQL 
     ,    -
  . 
 ,       , 
     ,    .      
 ,         , 
        -
        .  
       : 
spdf = pdf 
      :    ,   
   ,    .    -
  . 
   ,        
   ,         
      :  
          
  ,      , a  
        . 
         
API,    PDFlib    .    
  19, ,   ,     
  gd       PDFlib. 
     .     
        -
 PDF-,          
   .     , 
      . 
      . -
   ,    
       .   
   1 .     
    (    10): 
          
     . 

 30.      PDF 
     ,      -
   1 : 
       -
   .       
            -
  .  ,      
   ,        
 .    ,   
  
"PHP 
   "PHP Certification"     . 
       ,    
      .    
= "tiff", 
200, 75, 
   ,    -
      TIFF-.     -
  .  , , ,    
       -
    .     -
.         -
  ,  1,       
           -
. 
         
PDFlib  .         -
   Windows-   ,   -
  . 
     ,   
. 
        ( ) , 
   (    ) -: 
0, .4); // - 
, , //  
   ,     ,   
: 
630, 
610, 
pdf lineto($pdf, 632, 
646, 
666, 
pdf 

624  5.      MySQL 
 ,    ,    
   ,         
      ,  -
      .    
       ,   ,  -
,  PDF-,     ,  
       . 
     -
     ,  .    
          , -
     ,     
 .  ,      cos()  
sin()   ,    . 
      ,  -
    .      
  ,      . 
      ,   -
  . 
   
  ,       , 
  ,    ,     -
  .    HTTP- content-type: 
 
) 
   ,        -
.  , Internet Explorer    -
     . 
 , ,       
.       .  ,  
  GET   POST    
   . 
       PDF-,   
      ,     "Hello, World!" 
  PDFlib. 
   ,      -
 :   Netscape,    Internet Explorer. 
     PDF-,  -
 Internet Explorer,    Acrobat Reader.  
 Adobe        
       PDF-   
Active Server Pages,     . 

 30.      PDF 
  
     , ,  
   ,        -
 . 
 ,     
,    ,    -
  ,  ,   . 
  
 ,   PDF ( FDF),   
    Adobe  : 

 
 
 
 4  MySQL 
 Internet 

  4 
 MySQL 
  Apache, PHP  MySQL   
   Web-.   -
    Apache, PHP  
MySQL    .  , 
     
UNIX  Windows NT. 
     : 
      CGI  
 
  Apache, SSL, PHP  MySQL  UNIX 
  Apache, PHP  MySQL  Windows 
   : phpinfo() 
    MySQL  Internet 
Information Server 
    MySQL  Personal Web 
Server 
    
     -
   Web-,   , 
   Web-.  , 
    ,   
   (Secure Socket Layer, SSL)  
  .    
 ,     -
    . -
       Apache, 
  MySQL   ,  , -
, ,    -
. 

628  6.  
     CG1   
   ,     HTML   
 ,    ,    -
  .        -
   CGI.        
  .   
Apache  PHP-      -
.        ,  -
 ,    ,    -
    Perl  . 
    ,    -
         -
.  ,      CGI,  -
   CERT (CERT Advisory  : 
    CGI ,   PHP- -
  Web-     CERT   . -
  ,    (  ),   -
 cgi-bin,      ,  
     .   ,    
   . 
      : 
      ,   -
  CGI. 
     - Web-    -
,       CGI.   -
      
   
,      . 
   CGI,        
  PHP-   Web-.   
     UNIX  :\ PHP-DIR\  Windows. 
    ,       
    ,  UNIX-  -
         
  
#! /usr/local/bin/php 
 ,    ,   -
  .  ,   CGI  PHP-  -
  ,   ,   Perl. 
            
 UNIX   CGI     Windows. 

 .  4  MySQL 
 Apache, PHP  MySQL  UNIX 
   Apache, PHP  MySQL   UNIX.   
,       . -
           Web--
,         (Secure 
Socket Layer, SSL).         , 
          . 
   Client URL 
     
(Portable Spell Checker Libraries) 
     PDF 
  
       PHP-.    
   ,      
 .          -
 . 
         
,      .     ,  -
      . 
       Red Hat Linux 6.2, 
   ,       UNIX--
. 
,   ,    . 
 Apache Web- 
     
 OpenSSL Open Source Toolkit (  
Mod_SSL) 
 RSARef   ,    -
  
 MySQL    
      
  ,  ,  ,  
 (root)   ,     : 
 Perl (  ) 
 gzip  gunzip 
 gcc  GNU make 
       ,  
    . 
   root   : 
      
        -
 
   Web-       

630  6.  
,   ,     root. 
    ,    tar-   -
   .   ,      -
   .      -
        ,  
     root. 
      : 
I 
    ,     prefix. 
,  !  ,    -
   root 
$ SU 
  .    ,   -
 
/tmp/download/ 
    : 
# - | tar xvf -
  ,   
cd . 
     MySQL.  configure  
 ,     configure  
configure       .   -
   ,      
t 
   configure    , -
  (    ): 
      ,    
(    configure : 
make install 
          
.  new-password   -,   new-password 
    root. 
# 
# cd 
# & 
# -u root password 
  MySQL     . 
          : 

 . 4  MySQL 
-p 
 . 
I Databases I 
-------------------
I | 
-------------------
   MySQL     .  
 ,  ,       
   .   .    , 
   : 
i mysql -u root -p 
 . 
reysql> 
-------------------+ 
| I 
| 
I test 
2 rows in (0.00 
   .      -
 root (,   ,   
    Apache,   
   .    ,     -
,    Apache.      
,     . 
cd 
gun zip - gz | tar xf-
cd 
cd 
,     .     
       : 
- | tar xvf -
f cd 
 configure     ,    -
 configure       ,   
 MySQL, Apache, PDFLib, cURL  PSPELL. 
 ,     .     -
  ,    ,    ( 
      ,   . 
f \ 
\ 
\ 
\ 

632  6.  
  (   )     
 : 
# make 
# make install 
     lib: 
 php.ini-dist 
   ,   . ,  -
   ,    max_execution_time  
  : 
60 
 
       Apache.   
   ,    rsaref-2.0.  , -
      RSA,     Web-
.     , , 
Lycos 
 Google 
    ,      
UNIX. 
     rsaref.  ,   
   ,    . 
# rsaref-2.0 
# cd rsaref-2.0 
gunzip - | tar xvf -
      OpenSSL,  
          
# cd rsaref-2.0 
 -rp local 
f cd local 
# make 
cd 
   OpenSSL.       
   CSR .     . 
 
         
 
gunzip c | tar xvf -
# cd 
# ./config \ 

 .   4  MySQL 3 
     : 
# make 
# make test 
# make install 
# cd .. 
 mod_SSL     Apache. 
-c | tar xvf - 
od 
. x 
# od . . 
 ,     Apache   . -
   mod_SSL  DSO 
(   ),   -
   DSO  Apache    INSTALL  htdocs/manual/ 
dso.html     Apache. Internet-  , -
 ,   DSO    
   ,  Apache  DSO    -
. 
# cd apache 
\ 
\ 
\ 
\ 
\ 
\ 
\ 
    
( SSL_BASE  RSA_BASE     -
.) 
    Apache      
. 
# make 
   ,     : 
Before you install the package you now should prepare the SSL I 
certificate system by running the command. j 
For different situations the following variants are provided: 1 
% make certificate (dummy self-signed Snake Oil cert) 
% make certificate TYPE=test (test cert signed by Snake Oil j 
% make certificate TYPE=custom (custom cert signed by own CA) 
% make certificate TYPE=existing (existing cert) 
Use when a vendor package 
the TYPE=test when you're an admin but want to do tests only, 
the TYPE=custom when you're an admin willing to run a real server 
and TYPE=existing when you're an admin who upgrades a server. 
(The default is TYPE=test) 
Additionally add (default) or to select 
the signature algorithm used for the generated certificate. 

634  6.  
I Use certificate to display the data. 
| Thanks for using Apache & S. I 
| -I 
     .    
,     . 
# make certificate TYPE=custom 
 Apache  : 
make install 
    ,    : 
You now have successfully built and installed the 
Apache HTTP To that Apache actually 
works correctly you now should first check the 
(initially created or preserved) configuration files 
and then you should be able to immediately fire up 
Apache the first time by running: 
start 
Or when you want to run it with SSL enabled use: 
staztssl 
Thanks using The Apache Group 
    Apache  .    
     httpd.conf  srm.conf,     -
 
     httpd.conf    
      4 .    
 . 
  httpd.conf 
>     
AddType 
AddType 
       Apache.     
 SSL,    .    -
 ,        SSL. 
       
cd 
Syntax OK 
start 
start: httpd started 

 .  4  MySQL 635 
 .1 
   
 
 Apache. 
 
Hey, it worked / 
The Apache webserver wassuccessfully installed on this website. 
If you cart see this people who own 1 
software and the 
add content to replace this placet 
. 
lave installed the 
They have to 
or else the at their 
are page of the site you please the 
administrator the site (Try to 
is running the Apache it has no other 
to Group, so please do not about this 
contents to the Apache authors. If you do. your be 
The 
Especially also read the 
has been included this 
I 
are allowed to use the images below on your Apache Web 
Thanks for Apache, and 
   ,       Web- -
 ,    . . 
        IP-.   -
  . 
   ? 
    .      
test.php,    .      -
       , 
        prefix,   
.         
<? ?> 
     . .2. 
  SSL? 
       SSL.     
       SSL: 
f stop 
# /usr/local/apache/bin/apachectl startssl 
       Web-  https: 
 

636  6.  
.2 
 
  
   
. 
Build 
Command 
  aw 
Support 
Safety 
' ..... 
i 
   IP-, : 
 
    ,      -
   .     -
  .     VeriSign  
Thawte,     ,    -
    
 (Certification Authority, CA).   -
   ,   
   ,     
. 
   Internet  
Netscape,       -
.  ,     
. ,   Netscape, 
  . .. 
 . Web- 
 , 
,  
  
  SSL-. 
 PHP  MySQL  Windows 
  Windows     ,   
    CGI (php.exe)   ISAPI (php4isapi.dll). 
 Apache  MySQL    ,    UNIX.  -
   Windows  ,     
    . 
  ,          -
   ,     .  
     

 .  4  MySQL 3  
  Windows 
    MySQL.     -
  MySQL        -
 Setup.exe.  ,    MySQL   
 C:\mysql.         
   . 
  MySQL ,     -
 ,    MySQL.     
   ,  -
 MySQL     mysqld  
 
   MySQL      -
    MySQL.   -
        . 
Windows 95/98 
 MySQL  Windows 95/98     MySQL: 
 mysqld:        -
   
    Pentium 
     Intel x86    . 
 mysqld      Windows  : 
    MySQL   .    -
, ,  ,      -
  ,    .    MySQL -
  
-u root shutdown 
Windows NT/Win2000 
   MySQL   NT  Windows 2000  
 .   MySQL     
nt     .    : 
-install 
   MySQL         
  
NET START 
NET STOP mysql 
    mysql,   
         (Services 
Control Manager, SCM) (    (Control  -
 NET START MySQL.  SCM   .   

638  6. 
      (startup parameters)  SCM  
  MySQL.    ,  
   NET STOP 
  MySQL    : 
root 
version status 
- root shutdown 
        -
 Windows. 
MySQL    : mysql  test.   mysql   
    .   test   , -
      MySQL. 
       Web- MySQL   
http://www.mysql.com. 
     Apache  Windows. 
 Apache  Windows 
Apache  1.3    ,    Windows NT 4.0 
 Windows 2000.        86 
(, Intel). Apache     Windows 95/98,   -
    .   ,      
 TCP/IP.  Win95  Win98      
2. 
 ( ,       ) -
   Apache  Windows     -
      Apache. 
       
 . 
       Windows ( -
  . .5)     . 
1 
Manual 
 .4   (Services Control 
Manager)   , 
   . 
 .5    
   Apache. 

 .   4  MySQL 
   : 
    Apache. (   C:\Program Files\Apache 
     Start. (Apache Web Server .) 
  .  Typical ()  ,  -
 .  Minimum ()    -
   .    ,    
Custom (). 
  Apache      -
         , 
  . 
 Apache  Windows 
       Apache: 
    
    Windows 
       Window NT  Windows 2000.  
  Apache        
  .   ,  ,  -
 Windows 95  Windows 98. ,    1.3.13   
 Win 95  Win 98  Apache  .  ,   
     . 
   Apache       ,   -
      .    
 Apache   . 
 Apache    
  Apache   ,    Start Apache as 
console App ( Apache   )   Start ().  
     ,    .  -
     ,   Apache   . 
      Shutdown Apache as Console App (-
 Apache   )   Start (),   -
        (  1.3.3  ): 
Files\Apache Group\Apache> apache -k shutdown 
   MySQL, Apache     ,    
,        
,    . (      1.3.3  -
.) 
 Apache   
  Apache  ,     . -
,         Apache   
  . 
   Apache   (  Apache),   
 Install Apache as Service (NT ( Apache   ( 

640  6. 
  Start ().    Services () ( Control Panel (-
  Apache   Start ().  Apache   
  .   ,  Stop ().   
 Services ()  Apache       
,    
NET START apache 
NET STOP apache 
 ,      MySQL  NT  
Windows 2000. 
Apache      NT  Win2000    
          
  . Apache     Event 
Log ( ). 
   ,         
 Apache.    Apache   ,   -
,        : 
apache "service name" -k start 
apache -n "service -k restart 
apache -n "service " -k shutdown 
           -
 -k     Apache,    .  -
  ,     . 
  Apache   80 (    -
     Port (), Listen ()  
(         , 
       
    ,   .    -
  Apache.       ,  -
    logs.      Internet,  -
  URL: 
 IP-    localhost. 
     (    80),  URL   -
 
 ,  Apache HE        -
    TCP/IP. 
     UNIX 
      Apache  Windows  UNIX: 
  Apache  Windows  ,    -
      ,     
 UNIX.       Apache: -
  ,     .   
    .   
       . 

 .   4  MySQL 
 ,     ,   
    Windows,   UNIX. ,  -
 Apache   UNIX,    ,  
   .    ;   -
,   ,      
Apache. 
 Apache  Windows       -
   .  Apache   -
,       \modules.  -
   -      
 LoadModule ( ). ,    
 (status)   (     -
 
LoadModule 
         
     1.3  Apache  Windows   -
.        
  ,     -
  .      CGI  Apache,  -
       Windows. Apache 2.0 -
        .  
 ,   NT/2000  CGI   
 . 
  Windows   Apache   SSL,   
     .  ,   ,  
        , 
    UNIX.    ,  
  . 
  
      Windows.     -
   Apache.   :     3, 
 4    ,     
DLL-.        CGI   -
 .    ,   DLL-   -
 (),     Windows.     
     SYSTEM (Windows 9x)  SYSTEM32 (Windows 
NT),    Windows.    
MSVCRT.DLL (     )  PHP4TS.DLL. 
  ,       . 
,  ,         
  Windows-. 
21 216 

642  .  
1.        -
       
 Windows 9    NT. 
2.   php.ini  extension_dir     -
, DLL- ,   doc_root   -
   Web- (..   ,  
 ). 
3.   php.ini     ,    
  .       -
,          -
  .  ,  MySQL    
 4         . 
,          conf -
 Apache.        CGI.  -
     : 
 /php/ 
 application/x-httpd-php 
 AddType application/x-httpd-php 
 Action application/x-httpd-php 
 ,   AddType   Apache,  -
     .     Apache 
        -. 
, ,       -. 
   : 
 AddType application/x-httpd-php 
 AddType application/x-httpd-php 
     ,     
 ,    Web- Apache http://www.apache.org. 
   
  Apache  ,    .   
    : 
<? ?> 
       Apache,   -
      
 
 ,  Apache    ,  ,     
 ,   . .2.     MySQL 
  .      PHP-,  -
    MySQL  /   . 

 .  4  MySQL 3 
   MySQL   Microsoft IIS  PWS 
          MySQL  IIS  
  ISAPI (php4isapi.dll).  ,   
,          . 
,      DLL-,    -
 (MSVCRT.DLL  PHP4TS.DLL)   Windows.  ,   
  test.php ,  . 
   Microsoft IIS 
       Microsoft Internet Information Server: 
       Windows 
       ( -
)    . 
2.  Microsoft Management Console (  Microsoft) ( 
 Internet Services Manager   Windows NT 4.0 Option Pack   
Control Panel, Administrative Tools ( ,  -
)  Windows 2000). 
3.       Web-   Properties 
().   ISAPI Filters ( ISAPI)    ISAPI. 
     . .6.     
       php4isapi.dll,    -
  4. 
4.   Home Directory ( )   Configuration 
()      Application Mappings ( 
).    php4isapi.dll    ,  -
 .php,   Method exclusions ( )   
  Script engine ( ). 
   IIS,   stop  -
 . 
-
j ; | 
 A.6 
    
 ISAPI. 
Hi* 

644  6.  
6.  IIS  start 
7.   test.php     Web-.  
test.php,   ,  : 
<?php ?> 
   ,    ,   . .2. 
   Microsoft 
1.    DLL-  ,    . 
2.     PWS-php4.reg,    
       
, : 
Script Map] Files\ 
3.  PWS Manager ( PWS)      -
,      ,   Properties (). 
  Execute ()   . 
  !   PWS     . 
  
  MySQL       Web-, -
 Omni,  Netscape Enterprise Server.       -
,        Web- 
MySQL  : 
 

 
 Internet 
     -
   Internet,   -
, ,    PHP-.    -
 .  ,     -
   ,    MySQL,   
 ,     Web- -
  . 
      , 
,      
     -
   
  
PHP.Net  http://www.php.net    .  
      ,   
   . 
ZEND.Com  http://www.zend.com    
ZEND,      4.0.  
-  ,     -
   ,    -
.   . 
PHPWizard.net  http://www.phpwizard.net   
   , , 
phpMyAdmin,     
  MySQL.  ,   
   . 
PHPBuilder.com  http://www.phpbuilder.com   -
   .      -
    .  , -
    ,    
 . 

646  6.  
DevShed.com  http://www.devshed.com  -,   -
   PHP, Perl    .  
  . 
- Code Exchange  http://px.sklar.com     .   -
        . 
The PHP4 Resource  http://www.php-resource.de     -
,   . ""       -
.         . 
WeberDev.com  http://www.WeberDev.com     "Berber's PHP sample 
page",             -
 .       MySQL    
,    NT.     .   ,  
 ,  ,     . 
HotScripts.com  http://www.hotscripts.com   ,   . 
     ,  PHP, ASP  Perl.    
  PHP-.   ,   -
  ,    . 
PHP Base Library  http://phplib.netuse.de  ,   -
    3.         
,      4,      -
   .    ,     . 
 Center  http://www.php-center.de    -   , 
  , ,    . 
PHPInfo.net  http://www.phpinfo.net       -
    MySQL,   , , ,    -
    . 
 Homepage  http://www.php-homepage.de     , -
 : , ,    .    . 
PHPIndex.com  http://www.phpindex.com     
  ,  .   ,   
  , ,      . 
WebMonkey.com  http://www.webmonkey.com      Web--
,  ,    ..    -
, ,    ,    . 
The  Club  http://www.phpclub.net   Club     
   : ,  ,  , , 
    ,     . 
The PHP Classes Repository  http://phpclasses.upperdesign.com     
    ,   .   -
       ,    
.     . 
The PHP Resource Index  http://php.resourceindex.com  - ,  
 .      ,    . 

 .  Internet 7 
PHP Developer     PHP-: , -
,  . 
Evil Walrus  http://www.evilwalrus.com     . 
Oodie.com  http://www.oodie.com       -
,      . 
  , ,      
    . 
Source Forge        -
. Source Forge      ,    
  CVS,       -
    . 
 MySQL  SQL 
The MySQL site  http://www.mysql.com   Web- MySQL.  
 ,    .  ,  
 MySQL.       MySQL. 
SQL Tutorial  http://w3.one.net/~jhoffinan/sqltut.htm     
SQL      . 
The SQL Course      SQL  -
 .       -
 SQL.      
DatabaseCentral.com       -
   .   , ,  
,     ,   ..  ! 
The SQL Pro      -
?   !       , -
     SQL. 
 Apache 
Apache Software  http://www.apache.org  ,    ,   
     .    . 
Apache Week  http://www.apacheweek.com    , -
  ,    Apache    . 
Apache Today  http://www.apachetoday.com     -
  Apache.       
. 
  Web 
  Web-     (Philip and Alex's Guide to 
Web Publishing)     
       Internet.   
        Samoyed. 

 
 
- 36 
% 192 
& 42 
&& 44 
. 35, 39 
= 39 
== 43 
?: 45 
@ 45, 326 
46 
I 111 
II 44 
 
  198 
  256 
 163 
 163 
 163 
 163 
 163 
  325 
 33 
  39 
 388 
 Web-  166 
 47 
  76 
 141 
 262 
 247, 254, 265, 266, 
HTTP 274 
 272 
 272 
 418 
  
 221 
      
    
 415 
     
  352 
 246, 264 
 GD 341 
  136 
  72 
 221, 262 
 
 111 
    135 
   MySQL 263 
   HTML 29 
 108 
 
 
   .  
 
  198 
 
 338 
   338 
  60 
   
 42 
 30, 140 
 30 
 256 
  ,   
 RFC 317 
  390 
 478 
FTP 478 

  649 
 
 413 
 432 
432 
 434 
 432 
  66 
   65, 400 
 254 
   271 
  39 
 
 36 
MySQL 181 
 362 
  265 
 76. .   
 140 
 42 
 140 
 469 
 54 
 
   (CSS) 392 
 108, 140, 141 
  143 
   149 
 141 
  148 
  142 
 141 
  143 
 treenode 582 
 76, 160. .   
 161 
 160 
 387 
 386 
 385 
 392 
  384 
 387 
 
CREATE TABLE 177 
DESCRIBE 180 
GRANT 172, 216 
170 
 
170 
REVOKE 175 
SHOW 180 
 32 
  385 
 Web- 234 
 Zend Technologies 393 
  68 
  35 
 38 
 
 
 35 
  44 
 
 75 
 76 
    78 
 80 
  83 
   76 
  76 
   529 
 480 
  148 
 279 
 
  108 
 141, 146, 148 
 148 
 
  39, 131 
   193 
 193. .    
 
   (equi-join) 193 
     194 
 140 
-  
 39 
 
break 58 
continue 58 

650   
 
CREATE TABLE 178 
DESCRIBE 225 
describe user 217 
do. 57 
each 79 
else 51 
elseif 52 
EXPLAIN 225 
for 56 
if 51 
123 
INSERT 189 
LOAD DATA 231 
return 135 
199 
SHOW 224 
SHOW GRANTS 224 
switch 52 
while 55 
 31, 39 
PHP 31 
 39 
,  50 
 40 
 39 
   46 
 44 
  338 
  45 
 44 
 40 
 43 
 & () 42 
 40 
 45 
   68 
 
 392 
 229 
 229 
  214 
    FTP  HTTP 
63 
    68 
      
(ODBC) 215 
 396 
 410 
 404 
 161 
"  " 161 
"  " 161 
"  " 161 
  317, 525 
    211 
 51 
 396 
  396, 398 
   408 
 396, 402 
  408 
 396 
 396 
 
GPG 293 
 129 
 222, 268, 427 
   428 
  427 
 268 
 270 
  129 
   133 
   133 
 146 
 131 
 34 
 131 
 131 
 38 
  36 
 34 
 
 141 
 258 
 258 
 105 
  
  441 
 455 
 141 
  

  651 
  218 
  44 
  68 
  516 
  229 
  384 
  37 
 171, 216 
  174 
  174 
 222 
222 
PROCESS 222 
RELOAD 222 
SHUTDOWN 222 
 175 
 
Certification 605 
PHPBookmark 414 
Shopping Cart 445 
Warm Mail 503 
 47 
 31 
 Term SSH 325 
  396 
 288, 316, 361, 501 
316, 323 
HTTP 288, 316, 361 
317, 501 
NNTP 501 
POP 317 
501 
Secure Socket Layer 260 
SMTP 317, 501 
TCP/IP 288 
 391 
 196 
P 
   455 
  
 262 
  108 
  61 
   263 
 137 
 
 361 
  362 
 361 
 
Apache 260, 274 
Microsoft IIS 260 
 376 
 259 
  234 
  401 
 444 
 CVS 388 
 
MySQL 171 
NASDAQ 
  388 
    73 
   (SSL) 287 
 
 500 
  427 
 
Web- 381 
 343 
 391 
  
 571 
 344 
  
  529 
  104 
  (IDE) 389 
 42 
 33, 35, 97 
   
  
  104 
  97 
  97, 98 
  40 
  
 141 
 74, 158 
 

652   
 284, 378 
463 
495 
index.php 451 
page.php 487 
621 
PHP 284 
498 
482 
496 
show_book.php 454 
456, 462 
php 492 
494 
589 
   378 
    
 378 
 
  69 
  307 
  67 
70 
   70 
 
 159, 165, 177 
 229 
 217 
 177 
  
 352 
    353 
  
  571 
 394 
 
BLOB 185 
186 
186 
  
   183 
   
  36 
  37 
  71 
  361 
  50 
  97 
  50 
 myisamchk 229 
  
 60, 302 
  72 
 60 
    302 
  66 
   65 
  68 
   71 
   70 
  61 
   69 
   67 
  71 
 
.htaccess 275 
451 
content.html 275, 277 
291 
121 
header.inc 121 
120 
605 
469 
page.inc 151 
 598 
ASCII 598 
HTML 598 
PostScript 600 
RTF 599 
  (PDF) 596 
 
 480 
 97, 98 
  341 
GIF 342 
JPEG 341 
PNG 341 
342 

  653 
  65 
 571 
 387 
 125, 198 
PHP-MySQL 214 
   
    48 
    307 
 339 
   MySQL 198 
  129 
  320 
 259 
 
433 
add_quoting 592 
207, 290, 377 
92 
array_reverse() 87 
91 
85 
309 
461 
461 
556 
510 
425, 426 
336 
312 
312 
312 
copy() 312 
92 
90 
33, 333 
DATE_FORMAT() 337 
423 
452 
38 
delete_account() 515 
delete_bm() 436 
dirname($path) 309 
151 
513 
display_account_select() 518 
512 
473 
454 
509 
 
458 
display_categories() 452 
509 
548 
display_list() 518 
558 
560 
555 
display_tree() 581 
dl() 378 
do.html_header() 417 
624 
79, 90 
49, 50 
end() 90 
ereg() 113 
113, 319 
407 
escapeshellcmd() 290 
eval() 375 
exec() 313 
expand_all() 580 
89, 102, 322 
93, 94 
66 
feof() 68, 70 
fgetc() 70 
68, 69 
fgets() 68, 69, 70 
68 
(ile() 69 
311 
311 
71, 311 
311 
421 
flock 72 
fopen() 61, 62, 63, 64, 65, 68, 69, 319 
fpassthru() 69 
fread() 70 
72 
71 
326 
328 
330 
329 

654   
 
65 
get_account_list() 516 
get_accounts{) 513 
get.archive() 553 
144 
get_categories() 452 
454 
378 
get_email 546 
377 
377, 378 
375 
get_post() 589 
592 
430 
493 
550 
491 
321, 322 
378 
getmxrr{) 321 
48, 49 
346, 363 
379 
379 
290 
285 
isset() 50 
85 
344 
344 
347 
345 
358 
351 
346 
347 
345 
ini.get() 378, 379 
378, 379 
465 
552 
425, 545 
311 
mail() 96 
309 
rnktimef) 335 
92 
92 
 
214 
mysql_connect() 209, 400 
mysql_create_db() 214 
210 
mysql_drop_db() 214 
210 
211 
214 
214 
210 
208, 213 
209, 210, 213 
mysql_result() 211 
210 
90, 91 
98 
431 
47 
516 
519 
308 
parse_url() 322 
313 
90 
90 
494 
readdir($dir) 308 
readfile() 69 
438 
422 
312, 313 
79, 90 
429 
retrieve_message() 522 
71, 72 
308 
309 
566 
send_message() 526 
376 
363 
session_register() 365 
364, 370 
144 
49 
379 
86 
83, 85 
103 

  655 
 
543 
514 
593 
290 
104 
105 
104 
101, 210 
106 
strnatcm() 104 
104 
559 
106 
106 
strstr{) 105, 399 
102, 103 
554 
313 
298 
312 
97, 207 
309 
337 
71, 298, 312 
unserialize() 376, 377 
554 
85, 86, 91 
valid_email() 421 
X 
 344, 350 
 388. .  
259 
 571. .    
 
57 
for 56 
while 55 
  258 
  259 
 
  516 
 
 256, 292 
   257 
   258 
 
  143 
 
 30 
SGML 30 
XML 30 
  (Data Manipulation 
Language) 188 
  (Data Definition Language) 
188 
  (SQL) 187 
  
Active Server Pages (ASP) 31 
Cookie- 362 
478 
PHP 33 
- 30 
31 
34 
SGML (Standard Generalized Markup Language) 30 
Web- 571 
XML (Extensible Markup Language) 30 

ISBN 
384. 
PHP.   
 
 .     -
       , -
  HTML-.   ,  
       ,   -
       
    Web-,   -
 ,    Web    . 
      .   -
        
    .   
 ,      -
 ,       
    . 
       
Internet-  . 
.  
 .        
 .    , 
  ,   -
      ,   
      Web--
. 
      :  
,    Web-,   
Internet-,  ,  -
    ,   -
.      . 
       -
       
   . 

 HTML. 
  
Web- 
    
  HTML  -
 Web-   . -
 Web-  Web-,  
      
 ,   -
.        -
     -
 Web- Ducks In A Row (http://www.ducks.htmlbook.com).  -
        .  -
   HTML 4,     .  -
    CD-ROM     -
 . 
  
ISBN 
464 . 
 1.  
 2.   
 3.   
 4.   
 5.    
 6.    
 7.    
 8.  
 9.  
 10.    
 11  
 12.  
 13.   
 14.  
 15.    
 16.  
 17.    
 18.      
 19.   HTML- 
 
  

 
  Python. 
 
ISBN 966-7393-54-2 
, 336 .  
 
 
 
   
  Python   
  ,    -
    . 
   : 
   ,  
      
  (,  Linux  
UNIX). ,    Python, 
   ,   -
    
.     
  CGI (   
  Apache).    
     -
 ,  ,  
Delphi, MFC, Java,   
      -
. 
  ,    , -
  ,     
 .   
     -
  ,    -
   . 
  ,  
  .      
  . -
,       
    , 
     .  
,     -
   .   
    -
. 
    , 
 , 
,  
   
     
   Python   -
 .   -
:    
      (, 
C++),     , -
 , ,   
   
   : 
     -
 (   
  ).    -
  ,   -
    (, 
map, filter, zip),  -
  (lambda). 
       
  ,   
,  .  
   
-  -
   -
.   PLEX    -
   -
,     
,     -
 . 

  
 
ISBN 
175x250 ,  
Python    -
    
,    Web.  -
       
      
. 
  Python   -
  Microsoft UNIX/ 
Linux  Macintosh.    
 Python     
 . 
    ,  -
   ,   
 Java. 
    -
 Python      
,      -
   .   -
     : 
     OLE, COM, DCOM 
 ActiveX    
    Windows ( win32com, 
 Python Delphi  .); 
    -
    CORBA, ADO, DCOM 
( CORBA Parser, Fnorb, Hector  
     ,  
    -
   ( JPython  .); 
  ,   
,  
 Python 
   , -
     
 ,   MFC, Tk, Motif 
   ( Pythonwin, wxPython, 
PyKDE, PyOpenGL  .); 
  -
    ( Zope, MetaKit, -
 shelve); 
    ,  
 ,   
    ; 
  ,     -
   ,  XML, SGML, HTML, 
XDR. 
   ,    -
     "Python. -
 ".    -
 ,     -
  Web. 
  ,   , 
  Python:  
 ,    , 
 ,   -
   

   
JavaScript 
  
ISBN 966-7393-62-3 
210x270 , 464  
  
 JavaScript     -
       -
   Web.      
   
    
,      
 "JavaScript.  
       
  JavaScript 
    
  , 
   ,   
   . 
      
        
  .  ,   
JavaScript    
, ,   -
        
.        -
 ,    ? 
,     
 , ,   Perl  
Python.   ,     
   ,     -
     
JavaScript. 
   
   ,  -
      . 
     , 
..     -
. 
  
   , 
     
    ,  
        
  ,     
-     
  . 
      
     
JavaScript      -
  . 
      
    -
 HTML,       
 ,   -
,  Web-. 
   JavaScript    
,     ,  -
     
    
 . 
  
  JavaScript     HTML. 
  , , , 
   . 
    / 
 JavaScript. 
     -
. 
     
  
      
-. 

  
  
  Internet 
ISBN 
150x210 , 448  
PUE 
 ,  -
     . 
     
,  Internet     
    .   
      
   . 
 
      -
    ,   
   ,   -
.    ( ,  )  
"  ,   
     
 Internet?  ,    , 
,   ,   -
,    
  ,     :  
 ,      
  . 
      , 
    Internet. 
       
  . 
   ,    
  Internet,    
   . 
   ,     -
        
Internet  .      
 ,      
  Internet. 
   
   
,       
 Internet   
  ,    , -
       
 . 
      , 
        , -
 . 
       
.    ,  
  .    
   ,   -
     .  
      (  
)    .    
        
  .   ,  
 . 
       
 Internet.  ,     
     ,  
       
. 
    
. ,    ,   , 
       
. 

 ,   
  Flash 5 
  
ISBN 
175x250 , 496  
 
 
   
 Flash  , , 
     
 . , 
      
      
Flash 5     
   , , , 
   ,  Web,    
 
  Flash 5 *  -
    Flash 5, -
  ,    -
, ,    
 .     
   ,  
Flash    ,     
Macromedia,  
 ,     
   Flash  
         
  Flash 5,     
  ,     -
   .    -
     
, ,  -
,    ,   
    .  ,  -
     
   Flash,     
  ,    -
  no Flash. 
  
    ,      
 Flash,     ,     
,    
,     , ,  
   
         
  Flash,       
    Macromedia, 
Fireworks, Generator  Director. 
     
  ,      
    
   Flash   -
 . 
 ,    ActionScript,  -
    
,       
.        
   ,   
  ,  -
 Flash    
   . 
       
no Flash,      , 
 , ,     
  ,    -
  Flash    -
. 

  . 
 Internet- 
 Delphi 2 
ISBN 966-7033-20-1 
150x210 , 640  
PUB 
 ,  -
   Internet     
    Internet,  
  ,    
 . 
     
    
     
   . 
   
    
   
 ,      
  CGI   
   -
    
Internet 
     
Internet,   CGI 
    
Web-,  
 
  Internet 
     -
,   .  
      
  ,    
     Delphi. 
    , 
  ,    

 
 
 
   C++ 
/ 
/ 
      -
 ,     
:   , -
  ?    ? 
   ?    
   ?  
  :   -
     , -
      -
      . 
 ,     -
,  "   -
,   .  
     -
     -
  ,  -
.     -
   
,    
       
  (  ) . -
     -
,      -
   - .  
    (, -
),    "- 
"",   .  
   "" -
 "" (,    
 !)...  ,  -
 ?     ,    
?  ,  -
    
  
  , 
    
 "".  ,  
 ,  
     
    
 ( ,    
 , -     -
  )?  -
       
? 
  :  (-
)   ,   -
     ,   
     -
.      
  ,     -
 .   , -
      -
  . 
        
   -
  ,     
 "".  ,   -
,       
   .   -
   -
 ( ,   ). 

  
Windows 2000 API. 
  
ISBN 966-7393-74-7 
175x250 , 1088,  
 
 
 
 
 Windows    
      ( 
     ,  "windows" 
      Windows 
      
: ,  , , , 
,  ,   (  
,   ,  , 
 ). 
     , 
        
,    ,  
     ,  
      .   
      -
,        
     
. 
      
  .     -
,   (   
  ,     
 ,    ),   
   . 
   
,      
.         
  :   
    -
 programming interface)  
Windows         -
    
     
   
   
 
    
  2000 API. 
". 
 
      
      , 
  Windows 95.  API  , -
  Windows 2000,     -
,       
  .        
 Windows,    API, -
  
      
     API Win32,  
   Windows 2000  Windows 98 
 Microsoft.     
    , 
   .     -
  API Win32,   
  ,     API Win32, 
     API, 
  2000. 

   -  -
 ,      -
  ,      -
   ,   -
  ,   .  
    -
 ,   ,   
  .  
     ( -
     ""), -
    --
   , -
  . 
     -
     -
     -
   Cyrix  . -
     , 
     , 
      , 
       
     
   , -
, .    
   , -
    . 
 ,       
-  ,  
      
   -
. 
 
, , , 
   . 
  
ISBN 
150x210 ,  
     
 ,   
    
 ! 
   
      
  -  
      
 Intel, AMD,  .    
     -
    Intel 8088  AMD486DX 
 Pentium 4,  Athlon,   
 , , ,   -
.       
   
   . 
     -
       .  , 
   BIOS   -
 ,     
    Windows 95  Millenium 
2000. 
      
 .     -
      
  .    -
   ,  
    . 
,     
    ,  
     -
     . 

     
-    -
,     
 . +  - 
  ,   
    
    . 
  
      -
 ,      
    no  
 -     
   .    
     Windows 
DNA    . 
     
.      -
,  ,   , 
       
.     -
  .  ,    -
    -
 .   
      
  . , , ,  -
        -
      
      ?  -
-      - 
  ,     -
  " "    -
 ,      
? ,    !    -
    
    ,     -
-       
    ,     
  . 
  
  
ISBN  
 
 
 
 , 
 
   
 
  
  
 
 
 
  
 
   -
  
.   , 
 
 -
  -
 ()      Microsoft DNA. 
      
    DNA.  
,      -
    . 
 "  
   
      
  , 
.    
  +. 
  , "   
",    -
 Microsoft Transcation   
     -
 ,  ,  
 . 
 , "  -
",   MSMQ 
     -
      
  ,  -
     
  . 

  
(   
         ,   , 
       .        
      .      
   ,   -,      
    www.diasoft.kiev.ua. 
 :      ; 
  ,      ; 
      ; 
      ; 
     . 
 ,        - 
      ,    
 ,  ,      - ,  (  
), ,    ,     ..      
    www.diasoft.kiev.ua 
   
      ,          
 ,  ,            
        ѻ. 
       ,    . 
          ѻ     ѻ ( 
   ).    (  ,   ,   
       ѻ)    ,  
 ,     .       , -
   ,    . 
  
   ,       5%     
(  +  1000      ). 
       ;     . 
              10% . 
       ,       
www.diasoft.kiev.ua. 
  
2. ,   ,  (   )    
3. ... 
4.    
5.    
6. , , 
  
   : , 03055, -55, / 100,  

  -  
 
 
 
. .  
 
- 
- . 105 
. , 
\ 100 
Dks@diasoft.kiev.ua 
-; 49008, 466 
diasoff@mail.dnepr.net 
 . ' 
e-mail: 
j .' ' : 
./. 
.(0482) 
e-mail: kvant@eurocom.od.ua 
e-mail: kvant@tekom.odessa.ua 
 
.(095) 726-80-67 
[ e-mail: 
I e-mail: 
 
" 
 
" 
 , 
     ѻ 
 
 
- , 29 
 
" 
1 
 
 " 
40 
 744-86-72 
 
" 147  
 (0622) 
  
"-" 
1 
 (0564) 
 
 
.72-54-06 
 
4,5, 
 
58 
 
" 
" ,37, 
 
" 
 137-60-38 
 
, 
-,78 
. 
.2-  
, 2S 
- 
" 
 ", 
 
 
XXI" 
92, 
.. 
64-27-97 

      
  
1)    , -    
   
2)      
3)     ,      ,   
e-mail 
4)              
     e-mail.         
        
          
!     -
5)     ,   -   
         
       -
    ,   -
 ,   . 
        . 
     . 
      ,     
         7 . 
        . 
 
 
 : _ 
  
 
 
 -  
  
,. 
/ : 
E-mail: 
   - 
  -        : 
100, books@diasoftkiev.ua 
stepanb@akcecc.kiev.ua 
www.diasoft.kiev.ua       

-  
 
4756 
5616 
6700 
4043 
5611 
5164 
4683 
5228 
4020 
9 
5612 
2759 
306 
5511 
5003 
44 
4653 
5453 
5758 
3926 
5164 
5641 
4844 
5717 
936 
1557 
4318 
5462 
4982 
4754 
5804 
3850 
5063 
5056 
3621 
5845 
5419 
2757 
242 
93 
2758 
5799 
1057 
5571 
650 
5720 
5149 
6721 
5258 
5165 
5355 
5512 
2472 
5803 
 
 
, 
 .,  
  
 i 
  
 . 
 .,  
 
 . 
 . 
 
 . 
. 
 
 . 
 
  
 
  
  
. 
 .   
P., 
 . 
 
 
 . 
 
 . 
. 
 . 
. 
. 
 . 
 . 
 . 
. 
 
 . 
 . 
 . 
  
 , 
 Ban 
.  
.. 
  
 . 
 
 
 
    . 2- . 
  .  
, , ,  
   
  
    
   , 
5 
9 
15,9 
19 
30 
39 
25 
29 
34 
 
. 
   
79 
95 
195 
150 
195 
169 
160 
208 
672 
584 
400 
544 
720 
548 
  
  Windows 
  Windows Me 
  Windows 98. 
Windows NT   ( + 
Microsoft Windows 2000 Professional.  
  Windows 2000.  : 
     Warp 
4 
16 
25 
5 
49 
75 
5 
79 
150 
395 
Linux, Unix 
Red Hat Linux 6.0.  
 Red Hat Linux  Windows 
Linux IP Stacks   ( ) 
5.2.   + 2 
   Linux 
 Unux. 
 Linux   (+ CD) 
Red Hat Linux   . 
  Unix ( +  ). 
Unix   .  
UNIX    ( + CD-I 
19 
24 
29 
29 
39 
39 
39 
59 
40 
80 
95 
95 
120 
170 
145 
195 
195 
215 
290 
250 
470 
480 
0 
304 
608 
592 
832 
640 
352 
401 
400 
288 
400 
688 
488 
672 
830 
864 
496 
 
  C++.    
  .    
C++   
  .  
  Visual Basic 6.  
 Visual C++ 6  . ( + ) 
Visual  ++ 6  MFC.  . ( + 
Delphi 4.  ( 
Delphi 6.    .    
Delphi 5.    .    
Delphi 4.   ( + ) 
Delphi 2.   ( + ). 
     Delphi 
Borland C++ Builder 3.   ( + 
1.0.    .   
Power Builder 6.0.  ( + CD-ROM 
Windows 2000 API.   ( + 
 Internet-  Delphi 2 ( + CD-ROM ). 
PHP.  
  Python.  
.  
Server  + ) 
JavaScript   
JavaScript.   ( + CD-ROM j 
29 
29 
53 
59 
29 
23 
75 
9 
19 
25 
29 
35 
49 
45 
19 
35 
64 
9 
29 
29 
31 
49 
19 
14S 
179 
275 
295 
165 
150 
390 
45 
95 
120 
225 
95 
180 
320 
45 
150 
150 
155 
269 
95 
289 
656 
432 
584 
736 
480 
496 
720 
192 
576 
592 
400 
736 
512 
800 
288 
816 
1088 
640 
448 
336 
384 
480 
304 
464 
70x100/16 
70x100/16 
70x100/16 
70x100/16 
60x84/16 
70x100/16 
70x100/16 
84x108/16 
84x108/16 
84x108/16 
70x100/16 
84108\16 
70x100/16 
70x100/16 
70x100/16 
70x100/16 
70x100/16 
84x108/16 
70x100/16 
  
Adobe Photoshop 6.0.   
  Adobe Photoshop 5 ( + ) 
Adobe Photoshop 6.0.   
4 
19 
20 
95 
96 
32 
304 70x100/16 
 

169 
551S 
5002 
4634 
3925 
649 
570 
2471 
5069 
5029 
5262 
2101 
4763 
5163 
5064 
4753 
3924 
4303 
5139 
5096 
942 
4925 
5057 
1493 
5640 
2010 
3947 
3927 
1295 
1032 
5510 
40 
802 
314 
4849 
 
. 
. 
Ҹ . 
. 
 ., 
 
. 
 . 
 
P. 
 . 
  
 
  
 . 
 
. 
  
 ., 
 
. 
 
  
- 
. 
 .   
 , 
  
  
.  
 
 
Adobe Illustrator 9.0.  ( + ) 
6   ( + CD-ROM ) 
CorelDRAW 10   
3D Studio MAX 3.  ( + ) 
  3D Studio MAX 3 : , 
3D Studio MAX 4.  + 
  3D Studio  2.  3:  +  
  3D Studio MAX 2.  2: 
  3D Studio  3: 
3D Studio .  2- ( CD-ROM ) 
 3D Studio .  1 ( + ) 
  3D Studio  2.  1 ( + CD-ROM ). 
  Flash 4  . ( + CD-ROM ) 
  4   ( + CD-ROM ) 
  FLASH 5   CD-ROM ) 
Adobe  .   
 QuarkXPress 4  . 
   ( + ) 
AutoCAD 2000.    (+ ) 
  AutoCAD 2000. ( + 
  AutoCAD 14.   ( + 
36 
10 
29 
19 
19 
29 
29 
29 
29 
37 
60 
61 
19 
23 
29 
39 
39 
29 
29 
34 
49 
180 
100 
170 
95 
95 
150 
145 
145 
145 
180 
150 
150 
190 
215 
150 
180 
169 
368 
608 
880 
480 
456 
480 
408 
368 
720 
432 
752 
848 
448 
336 
496 
650 
704 
784 
688 
767 
70x100/16 
60x84/16 
70x100/16 
84x108/16 
70x100/16 
84x108/16 
84108\16 
84x108/16 
70x100/16 
70x100/16 
70x100/16 
84x108/16 
60x84/16 
84x108/16 
84x108/16 
     
Microsoft Office    
Notes  Domino R5.   ( + 
   Access 2000.  
Oracle 7.3.   ( + CD-ROM ) 
    
Oracle Server.  . 
Oracle 8.   ( CD-ROM ) 
MS SQL Server 2000. 
Informix.   
 .  Networking. 
 .  2: Networking Essentials. 
Microsoft BackOffice 2.   ( + 
  
    Internet 
     Internet 
  World Wide Web. 
   ( + ) 
  
29 
79 
75 
42 
75 
75 
160 
49 
60 
30 
65 
9 
9 
16 
5 
9 
15 
45 
145 
390 
390 
195 
470 
390 
245 
300 
180 
250 
45 
45 
125 
28 
45 
215 
552 
656 
544 
736 
800 
576 
864 
688 
800 
432 
432 
800 
460 
448 
544 
352 
368 
84x108/16 
84x108/16 
84x108/16 
84x108/16 
70x100/16 
84x108/16 
60x84/16 
60x84/16 
60x84/16 
---
rugame.mobi.ru -  ,, ,  , , , , ,   ...
