Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Самостоятел_2(2)

.pdf
Скачиваний:
6
Добавлен:
09.02.2016
Размер:
575.36 Кб
Скачать

<Files "*.tpl"> Order allow, deny

Allow from 127.0.0.1 Deny from all </Files>

 

 

%footer&

 

 

)

©

 

)-

 

 

)

 

 

 

*

©

 

 

 

 

 

 

)

 

*

)]

?ijslcabny .,,,-2001".

 

6

 

 

 

 

 

 

 

 

 

 

 

/2*.

 

-

©

 

 

*

 

 

 

 

 

/2*.

 

 

%footer.tpl)

 

 

 

 

<table width="95%" cellspacing="0" cellpadding="0" border="1">

 

 

<tr><td valign="top" align="middle">

 

 

 

 

 

Copyright © 2000 PHPRecipes. All rights reserved.<br>

 

 

 

<a href = "mailto:<?=$site_email;?>">contact</a> |

 

 

 

 

<a href = "<?=$site_path:?>/privacy.php">your privacy</a>

 

 

 

</td></tr>

 

 

 

 

 

 

 

</table>

 

 

 

 

 

 

 

 

</body>

 

 

 

 

 

 

 

 

</html>

 

 

 

 

 

 

 

 

 

 

 

 

 

!mcn_Z_g[cf

*

 

 

 

 

)

)

b_[^_l*njf iin_l*njf

 

 

 

*

©

 

 

 

!mcn_Zj[nb

 

Llcp[]s%

&*

©

 

 

 

-

QNH

 

 

 

 

jlcp[]s*jbj)

 

 

©

$

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

*

)

 

 

 

)

 

 

*

 

)

 

 

 

)

 

 

 

 

 

 

*

 

©

 

-

 

 

 

)

 

)

6

 

)

 

 

 

 

 

)

 

 

©

 

 

 

%© ©

 

&

 

 

6

)

 

*

 

)

 

 

$

 

q_ -

*

 

 

 

6b_[^_l*njf)ch^_rZi^s*njf iiner.tpl, -

©

 

 

 

)

 

 

/2*0

 

 

 

 

 

/2*0

 

ch^_r*jbj

 

 

 

 

<?

+6ch^_r*jbj

+

6

LDLN_]cj_m

+

6./

.,,, *

+

 

 

include("header.tpl");

+

include("index_body.tpl");

+

include("footer.tpl");

?>

51

;

-

*

/2.4

 

 

/2*1

DPIH)

/2*0%ch^_r*jbj&

<html>

<head>

<title> PHPRecipes </title> </head>

<body bgcolor="#7b8079" text="#ffffff" link="#e7d387" alink="#e7d387" vlink="#e7f0e4"> <table width = "95%" cellpadding="0" cellspacing="0" border="1">

<tr>

<td valign = "top"> PHP Recipes

</td>

<td valign = "top" align="right"> August 23, 03:17 pm

</td>

</tr>

</table><table width="95%" cellspacing="0" cellpadd1ng="0" border="1"> <tr>

<td valign="top" width="25%">

<a href = "htfp://localhost/phprecipes/tutorials.php">tutorials</a><br> <a href = "http://localhost/phprecipes/articles.php">articles</a><br> <a href = "http://localhost/phprecipes/scripts.php">scripts</a><br> <a href = "http://localhost/phprecipes/contact.php">contact</a><br> </td>

<td valign="top" width="75%">

Welcome to PHPRecipes, the starting place for PHP scripts, tutorials, and gourmet cooking tips and recipes!

</td>

</tr>

</table><table width="95%" cellspacing="0" cellpadding="0" border="1"> <tr><td valign="top" align="middle">

Copyright © 2000 PHPRecipes. All rights reserved.<br> <a href = "mailto :wj@hotmail .com">contact</a> |

<a href = "http://localhost/phprecipes/privacy.php">your privacy</a> </td></tr>

</table>

 

 

</body>

 

 

</html>

 

 

*/2*

)

*

)

)

*

52

 

*/2**

)

/2*0

 

Pcec

ek c co

k

 

)

)

)

 

*

©

)

 

*

kc

 

 

 

 

1.

*

 

 

2.

*

 

 

3.

 

*

 

53

 

oc

 

 

co

c

c

k k)

 

 

 

h]fo^_%& l_kocl_%&

 

 

 

 

 

 

 

c

 

 

 

 

 

 

*

 

 

 

k

 

 

 

 

 

 

 

 

 

1.

 

 

 

 

 

 

 

 

 

 

2.

 

 

 

 

 

 

 

 

 

 

3.

 

 

 

 

 

 

 

 

 

 

4.

 

 

 

 

 

 

 

 

 

 

5.

 

 

 

 

 

 

 

 

 

 

T

c c:

 

 

 

 

 

 

 

 

 

1.

©

 

- }LDL dMo_ls

 

 

)

)., )//0 *

 

2.

 

- }

 

 

 

)

6

).,,

).44

*

3.

**

- }

 

 

0) 6}

 

).,,

)/1. *

 

 

 

 

 

k

e o

 

 

 

 

 

 

 

 

 

©

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

©

q_ -

*

)

 

 

 

 

%

) )?((

F[p[&)

 

 

 

 

 

 

 

 

 

 

 

 

©

*

 

 

l_kocl_%& ch]fo^_%&*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6

 

 

 

include();

 

 

 

 

 

 

 

 

 

include_once();

 

 

 

 

 

 

 

 

 

require();

 

 

 

 

 

 

 

 

 

require_once().

 

 

 

 

 

 

 

 

 

©

 

©

)

 

 

 

*

 

 

 

include()

 

 

 

 

 

 

 

 

 

 

ch]fo^_%&

 

 

*

 

ch]fo^_%&6

 

 

ch]fo^_%cf_

&

 

 

 

 

 

 

 

 

 

ch]fo^_%&

 

 

-

©

 

*

)

 

 

 

 

 

c*

 

 

 

 

)

 

c

*

 

ch]fo^_%&

 

 

 

)

 

 

 

©

 

 

 

© *

 

 

 

 

/3*

37.2.

 

 

 

 

 

 

 

 

 

 

 

/3**

 

 

chclude()

 

 

 

 

 

if(some_conditional)

 

 

 

 

 

 

 

 

include('text91a.txt');

 

 

 

 

 

 

 

 

else

 

 

 

 

 

 

 

 

 

 

include('text91b.txt');

 

 

 

 

 

 

 

 

 

37.2.

 

 

include()

 

 

 

 

 

if(some_conditional) :

 

 

 

 

 

 

 

 

include('text91a.txt');

 

 

 

 

 

 

 

 

else:

 

 

 

 

 

 

 

 

 

 

include('text91b.txt');

 

 

 

 

 

 

 

 

endif;

 

 

 

 

 

 

 

 

 

 

 

 

 

)

)

$

 

*

 

© )

 

©

 

 

 

 

 

 

6

 

 

 

print "this is an invalid include file";

 

 

 

 

 

 

 

 

 

 

 

 

 

)

 

 

6

<?

print "this is an invalid include file"; ?>

54

 

include_once()

 

 

 

 

 

 

 

 

include_once()

©,

include(),

 

:

©

 

 

,

,

 

 

.

©

 

,

include_once()

,

-

 

 

 

.

 

include_once()

 

include().

ch]fo^_Zih]_%&6

 

 

ch]fo^_Zih]_%cf_ &

 

 

 

 

 

 

 

require()

 

 

 

 

 

 

 

 

 

require() ©

include() -

©

 

 

,

 

require().

 

require() :

 

 

 

 

 

require(file

)

 

 

 

 

 

 

 

, ©

require()

include()

©

.

)

 

 

l_kocl_%&)

 

©

 

©

l_kocl_%&

*

 

)

l_kocl%&

 

c

 

 

 

 

 

 

 

 

 

 

 

 

)

 

 

)

 

 

 

*

$

 

 

 

)

 

chcn*njf%

 

chcnc[fct[cih*n_gjf[n_&*

 

/3*/

)

©

 

chcn*njf*

/3*0

chcn*njf

 

 

 

l_kocl_%&*

 

 

 

 

 

 

 

 

/3*/*

 

 

 

 

 

 

 

<?

 

 

 

 

 

 

 

 

!mcn_Zncnf_9

N_]cj_m7

 

 

 

 

 

 

$contact_email = "wjgilmore@hotmail.com";

$contact_name = "WJ Gilmore";

 

?>

 

37.4.

init.tpl

<? require('init.tpl'); ?>

 

<html>

 

<head>

 

<title><? print $site_title; ?></title>

</head>

 

 

 

 

 

 

<body>

 

 

 

 

 

 

<? print "Welcome to $site_title. For questions, contact <a href =

 

 

\"mailto:$contact_email\">$contact_name</a>".; ?></body></html>

 

 

 

QNH

l_kocl_%&

 

 

©

QNH ij_h

ql[jj_lm%

©

&*

 

 

 

 

 

 

©

 

)

 

 

*

 

)

 

 

 

 

 

)

*

 

)

)

) ©

 

*

)

 

 

- require_once().

require_once()

 

 

 

 

 

 

l_kocl_Zih]_%&

)

 

 

 

*

l_koclZh %&

 

 

©

*

 

l_koc Zh %&6

 

 

 

 

 

l_kocl_Zih]_%cf_ &

 

 

 

 

 

 

 

)

 

 

l_kocl_%&*

 

 

Pcec

ek c

 

co

k

 

)

** /2

 

)

h]fo^_%& l_kocl_%&

 

 

 

 

 

kc

 

 

1.

ch]fo^_%&*

 

 

 

 

 

2.

include_once().

 

 

 

 

 

3.

require().

 

 

 

 

 

4.

require_once().

 

 

 

 

 

55

 

oc

co

c

c

(2

k k)

 

 

 

*

6

 

 

 

 

 

 

c

 

 

 

 

*

 

 

 

k

 

 

 

 

 

 

 

1.

 

 

 

 

 

 

 

 

2.

 

 

 

 

 

 

 

 

3.

 

 

 

 

 

 

 

 

4.

 

 

 

 

 

 

 

 

5.

 

 

 

 

 

 

 

 

T

c c:

 

 

 

 

 

 

 

1.

©

- }LDL dMo_ls

 

 

)

).,

)//0 *

2.

 

- }

 

 

)

6

).,,

).44 *

3.

**

- }

0)

6}

 

).,,

)/1. *

 

 

 

k

e o

 

 

 

 

 

 

)

 

 

 

*

 

 

 

 

*

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

/4*

 

%mcn_Zinit.tpl)

 

 

 

 

<?

+6mcn_Zchcn*njf

+

6

LbjN_]cj_m

+

6..

.,,, *

$site_name = "PHPRecipes";

$site_email = "wjgilmore@hotmail.com"; $site_path = "http://localhost/phprecipes/"; function show_header($site_name){

<html>

<head>

<title> <? print $site_name: ?> </title> </head>

<body bgcolor="#7b8079" text="#ffffff" link""#e7d387" alink="#e7d387" vlink="#e7f0e4"> This is the header

<hr>

}

function show_footer(){ ?>

<hr>

This Is the footer </body> </html>

<?

}

?>

/4*.

<?

+

include("site_init.tpl");

+

show_header($site_name);

?>

 

//

This is some body information

56

<?

 

 

 

 

 

 

 

+

 

 

 

 

 

 

 

show_footer();

 

 

 

 

 

 

?>

 

 

 

 

 

 

 

6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

6

 

 

 

 

 

 

8 bl_9 8;9!

Z6;:+

*jbj;

 

9! © :

8+:

 

 

 

 

*

 

 

) ©

 

 

%

/4*/&)

%

/4*0&

% /4*1&*

/4*/

 

%*bngf&

 

 

 

8b/: LDLN_]cj_m8+b/:

 

 

 

 

 

 

 

 

 

 

 

 

*

LDLN_]cj_m*

 

 

 

 

 

 

 

DPIH

 

 

 

Lilni_fi

 

©

*

 

 

 

 

)

6LDL

<p>

 

 

 

 

 

 

 

)

*

 

)

 

)

*

<i>0nly</i>

PHPRecipes.

 

 

 

 

 

/4*0

 

%

 

Z*bngf&

 

8b/:

 

 

8+b/:

 

 

 

 

)

 

 

 

 

LDL

 

 

 

)

©

)

©

©

 

 

 

*

-

 

 

)

 

)

 

 

*

 

 

 

 

 

 

 

)

 

 

 

 

<href="mailto:ads@phprecipes.com">ads@phprecipes.com</>.

 

/4*1

 

%

 

*bngf&

 

 

8b/:

 

8+b/:

 

 

 

 

 

 

 

;8l:

 

 

 

 

 

©

 

 

 

;8l:

 

<href="mailto:theteam@phprecipes.com">team@phprecipes.com</>.

 

 

 

 

 

 

*jbj)

 

 

 

*

 

% *

/4*1 &

 

 

 

 

 

Zchcn*njf*

 

 

 

/4*1

 

 

 

%

*jbj&

 

<?

+6mn[nc]*jbj

+

6

©

*

+

6

)

mcn_Zchcn*njf

+

 

 

© *

+

©

 

 

include("site_init.tpl") :

//

show_header($site_name);

+

include("$content.html") :

+

show footer();

57

?>

 

 

 

 

*

 

6

< href = "static.php?content=about">Static Page Name</a></br>

 

 

<a href = "static.php?content=advert_info">Advertising Information</a></br>

 

<a href = "static.php?content=about">Contact Us</a></br>

 

 

-

)

©

)

©mn[nc]*jbj

 

Pcec

ek c co

k (

 

1.

©

 

SA> -

% ©

 

&*

 

 

 

2.

 

*

 

 

 

 

kc

 

 

*

*

 

 

 

.*

 

*

 

 

58

 

 

Po ek o

6.2 - 4 4 ck ck

 

 

 

 

oc

co c

c

k k)

 

 

 

 

LDL

 

 

 

 

 

 

c

 

 

LDL*

 

 

 

 

k

 

 

 

 

 

 

1.

 

 

 

 

 

 

 

2.

 

 

 

 

 

 

 

3.

 

 

 

 

 

 

 

4.

 

 

 

 

 

 

 

5.

 

 

 

 

 

 

 

T

c c:

 

 

 

 

 

 

1.

©

- }LDL dMo_ls

)

).,

)//0 *

 

2.

 

- }

)

6

).,,

).44

*

3.

**

- }

0) 6}

 

).,,

)/1.

*

 

 

k

e o

 

)

 

 

)-

*

 

$

)

) $

*

 

 

)

IsOMH*

 

 

 

gsmkfZ]ihh_]n%& gsmkfZj]ihh_]n%&6

<?php

 

 

 

 

$server = 'localhost';

 

 

 

$user = 'root';

 

 

 

 

$password = 'P@ssw 0rd';

 

 

 

$dblink = mysql_connect($server, $user, $password);

 

if($dblink)

 

 

 

 

_]bi$

 

 

$7

 

else

 

 

 

 

^c_%$

 

 

$&7

 

+

!^fche

 

 

 

+

 

 

 

 

?>

)

6

<?php

...

$port = '12345';

$server = 'localhost :' . $port;

$dblink = mysql_connect($server, $user, $pass);

...

?>

mysql_pconnect()

mysql_connect() :

<?php

$dblink = mysql_pconnect($server, $user, $pass);

+ !^fche

+

?>

 

 

 

mysql_connect%&

$

)

 

mysql_close%&)

*

)

mysql_pconnect%&

)

 

 

% p

Persistent )

&*

 

mysql_pconnect%&

 

 

 

)

*

 

 

 

59

 

 

-

 

 

gsmkfZm_f_]nZ^%&*

 

 

)

 

 

 

 

 

 

6

 

 

 

<?php

 

 

 

 

 

 

 

 

 

$database = 'myDatabase';

 

 

 

 

 

 

$selected = mysql_select_db($database, $dblink);

 

 

 

 

if($selected)

 

 

 

 

 

 

 

_]bi$

 

 

 

$7

 

 

 

 

else

 

 

 

 

 

 

 

 

^c_%$

 

 

 

$&7

 

 

 

 

?>

 

 

 

 

 

 

 

 

 

 

 

 

^c_%&

 

-

 

 

*

^c_%&

 

 

 

 

 

 

 

 

*

 

^c_%& ©

 

 

)

 

 

 

*

)

 

 

©

 

)

 

 

-

 

©

 

*

 

 

 

 

 

 

 

 

 

)

 

 

$

*

 

)

©

 

)-

 

%]b[lm_n&*

 

-

 

 

 

 

*IsOMH

 

 

 

 

)

-

 

 

 

-

 

*

 

 

)

 

 

 

 

*

)

52-

 

 

 

)

 

 

x

 

*

 

 

 

 

-

 

)MySQL

 

 

latin %

 

&)

 

 

 

 

 

 

 

%

)

 

&-

 

 

 

 

 

 

 

 

;*

 

 

 

 

 

 

 

mysql_set_charset%&

 

 

 

 

 

SET :

 

 

 

 

 

 

<?php

 

 

 

 

 

 

 

 

 

if (!function_exists('mysql_set_charset')){

 

 

 

 

 

 

function

mysql_set_charset($charset, $dblink)

 

 

 

 

 

{

 

 

 

 

 

 

 

 

 

return mysql_query("set names $charset",$dlink);

 

 

 

 

 

}

 

 

 

 

 

 

 

 

 

}

 

 

 

 

 

 

 

 

 

$mycharset = "cp1251";

 

 

 

 

 

 

 

mysql_set_charset($charset, $dblink)

 

 

 

 

 

 

?>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

mysql_set_charset%&)

 

 

-

 

 

)

 

 

 

SQL -

*

 

 

 

 

 

 

 

 

PHP

 

 

 

 

 

 

 

cp1251

(Windows -

&

 

 

 

 

*

©

 

 

 

 

 

-

 

 

utf4%

&*

 

 

 

 

 

 

 

)

 

 

LDL

 

 

 

$

©*

 

©

 

)

$

)

 

 

 

)

 

 

* $

 

©

 

 

6

©)

 

 

©

 

 

 

 

 

 

 

 

 

 

 

©

 

gsmkfZjcha%&*

 

nlo_

[fm_

©

 

$

6

 

 

 

 

 

 

<?php

 

 

 

 

 

 

 

 

 

if (!mysql_ping($dblink)){

 

 

 

 

 

 

_]bi$$

 

 

$7

 

 

 

 

 

+

©

 

 

 

 

 

 

 

 

60