Вы находитесь на странице: 1из 427

-

-
2011
681.3.06
32.973.26-018.2
29

. .
29 AJAX . -.
.: -, 2011. 432 .: . + CD-ROM (
)
ISBN 978-5-9775-0629-8
Web-, -
AJAX,
. -
: - , .
PHP, xajax jQuery, Smarty
.
AJAX .
- -
, .
Web-
681.3.06
32.973.26-018.2

:

.
.





.

02429 24.07.00. 26.10.10.


70 1001/16. . . . . 34,83.
1000 .
"-", 190005, -, ., 29.
-
77.99.60.953..005770.05.09 26.05.2009 .
.

" ""
199034, -, 9 , 12.

ISBN 978-5-9775-0629-8 . ., 2010


, "-", 2010

............................................................................................................................ 1
............................................................................................... 1
................................................................................................................ 2
................................................................................................................... 3

I.
WEB- ................................................................ 5

1. Web- ......................................................... 7
1.1. HTML CSS ............................................................................................................... 7
1.1.1. .................................................................................................... 7
1.1.2. HTML ................................................................................................. 8
1.1.3. HTML ..................................................................... 8
1.1.4. .................................................................................................... 9
1.1.5. CSS ............................................................................................... 9
1.1.5.1. ................................................................. 9
1.1.5.2. ........................................................................ 9
1.1.5.3. .......................................................................... 10
1.1.5.4. ............................................................................... 10
1.2. JavaScript....................................................................................... 11
1.2.1. JavaScript ................................................. 11
1.2.2. JavaScript....................................................................... 12
1.3. HTML .............................................................................................. 13
1.4. PHP .......................................................... 16
1.5. MySQL ........................................................................................................... 17
1.5.1. ...................................................................................................... 17
1.5.1.1. ................................................................................................ 17
1.5.1.2. ............................................................................................ 18
1.5.1.3. .......................................................................................................... 18
1.5.1.4. ........................................................................................ 19
1.5.1.5. ................................................................................................ 19
1.5.2. MySQL ................................................................................................ 20
IV

1.5.3. SQL ........................................................ 20


1.5.4. PHP MySQL ................................................................ 22
1.5.4.1. mysql_connect .............................................................................................. 22
1.5.4.2. mysql_close ................................................................................................... 22
1.5.4.3. mysql_select_db ............................................................................................ 22
1.5.4.4. mysql_query .................................................................................................. 23
1.5.4.5. mysql_fetch_row ........................................................................................... 23
1.5.4.6. mysql_fetch_assoc ........................................................................................ 23
1.5.4.7. mysql_fetch_array ........................................................................................ 24
1.5.4.8. mysql_result .................................................................................................. 24
1.5.4.9. mysql_num_rows .......................................................................................... 24
1.5.4.10. mysql_insert_id ........................................................................................... 24
1.5.5. phpMyAdmin ....................................................................................... 25
1.5.5.1. phpMyAdmin ............................................................... 25
1.5.5.2. ............................................................................... 26
1.5.5.3. ................................................................ 26
1.5.5.4. ............................................................... 28
1.5.5.5. - ...................................................................... 29
1.6. .............................................................................. 31
1.6.1. ? ............................................................................................. 31
1.6.2. .......................................... 32
1.6.3. ............................................................................................ 35
1.6.4. .................................................... 39

2. AJAX .......................................................................................... 44
2.1. AJAX ........................................................................................................ 44
2.1.1. ................................................ 44
2.1.2. XMLHttpRequest ................................................. 45
2.1.3. ............................................................... 46
2.1.4. ............................................................................. 47
2.2. xajax ...................................................................................................... 48
2.2.1. xajax ............................................................................................. 48
2.2.2. xajax ............................................................................................ 48
2.2.3. xajax............................................................................................ 49
2.2.4. xajaxResponse ........................................................................ 51
2.2.4.1. assign ................................................................................................ 51
2.2.4.2. append .............................................................................................. 52
2.2.4.3. prepend ............................................................................................. 52
2.2.4.4. replace .............................................................................................. 52
2.2.4.5. remove .............................................................................................. 53
2.2.4.6. create ................................................................................................ 53
2.2.4.7. insert ................................................................................................. 53
2.2.4.8. insertAfter ......................................................................................... 53
V

2.2.4.9. clear .................................................................................................. 54


2.2.4.10. createInput ...................................................................................... 54
2.2.4.11. insertInput....................................................................................... 54
2.2.4.12. insertInputAfter .............................................................................. 54
2.2.4.13. removeHandler ............................................................................... 55
2.2.4.14. includeScript ................................................................................... 55
2.2.4.15. script ............................................................................................... 55
2.2.4.16. addEvent ......................................................................................... 56
2.2.4.17. call .................................................................................................. 56
2.2.4.18. alert................................................................................................. 56
2.2.4.19. redirect ........................................................................................... 56
2.2.5. xajax ........................................ 57
2.2.6. xajax ......................................................................... 61
2.2.6.1. ............................................................................... 61
2.2.6.2. xajax ................................................................................ 61
2.3. xajax ................................................................................ 65
2.3.1.
" " .................................................................................................. 65
2.3.2. select- ................................................ 70
2.3.3. ....................................................... 79
2.3.4. .......................................... 84
2.4. jQuery .................................................................................................... 92
2.4.1. jQuery.......................................................................................... 92
2.4.2. jQuery ....................................................................................... 93
2.4.2.1. $ .................................................................................................... 93
2.4.2.2. .................................................................................................... 94
2.4.2.3. jQuery ............................................................................................ 97
2.4.2.4. jQuery...................................................................... 98
2.4.2.5. jQuery ..................................................................................... 100
2.4.3. PHP jQuery .................................................................................................... 101
2.4.3.1. jQuery Carousel............................. 101
2.4.3.2. jQuery UI, Tabs Accordion..... 104
2.4.3.3. ............................................................ 113
2.5. Xajax Smarty ........................................................................................................ 127
2.5.1. Smarty .............................................................................................. 127
2.5.2. Smarty............................................................................................. 128
2.5.3. Smarty .......................................................................... 130
2.5.4. Smarty..................................................................................... 131
2.5.4.1. assign .............................................................................................. 131
2.5.4.2. display............................................................................................. 132
2.5.4.3. fetch ................................................................................................ 132
2.5.5. xajax Smarty ........................................................................ 132
VI

II. - ................................................... 139

3. ............................................................................... 141
3.1. .................................................................................. 141
3.1.1. (-
) .......................................................................................... 141
3.1.2. ............................................................. 143
3.1.3. ........................... 143
3.1.4. ........................................................................ 145
3.2. . ................................................................. 155
3.2.1. ........................................................................................ 155
3.2.2. ................................................................................................ 156
3.2.3. SESSION cookies ........................................... 160
3.2.3.1. session .................................................................................. 161
3.2.3.2. cookie ................................................................................... 162
3.2.4. ..................................... 164
3.2.5. ........................... 171
3.3. ............................................................................................................ 180
3.3.1. "" .................. 180
3.3.2. ............................................................................ 182
3.4. SMS a1agregator .................................................................. 190
3.5. "" ........................................................................................................ 195
3.5.1. .......................... 195
3.5.2. .............................................................. 199
3.5.3. "" .............................................................. 204
3.5.4. ....................................................... 206
3.5.5. ................................................................... 208
3.5.6. ............................................................. 210
3.5.7. ............................................................................. 217
3.5.8. ( ) ......................................................... 220
3.6. ................................................................................................................... 222
3.6.1. ....................................................................... 222
3.6.2. ........................................................................................... 227
3.6.3. ................................................................................ 230
3.6.3.1. ................................................................. 230
3.6.3.2. ................................................................... 231
3.6.4. .......................................................................................... 234
3.7. .......................................................................................................... 237
3.7.1. Webmoney ........................................................................................... 237
3.7.2. Webmoney ................................................... 242
3.7.3. ONPAY .................................................................... 245
3.7.3.1. .............................................. 246
3.7.3.2. ............................................................. 247
3.7.3.3. ONPAY Merchant API ............................................................................... 249
VII

3.7.4.
ONPAY Merchant API ........................................................................... 257
3.8. "" ......................................................................................................... 263
3.8.1. ..................................................................... 263
3.8.2. ....................................................... 267
3.8.3. .................................................................................... 273
3.8.4. ............................................................................................... 281
3.8.5. ............................................................................................... 284
3.8.6. . ............................... 285
3.8.7.
.htaccess .................................................................. 287
3.8.8. ............................................................................................ 288
3.9. ................................................................ 292
3.9.1. ...................................................................... 292
3.9.2. ................................................ 294
3.9.3. ....................................................... 296
3.10. ( ) ............................................................ 299
3.10.1. ............................................. 299
3.10.2. .................................................................................... 306
3.10.3. ..................................................................................... 308
3.10.4. ..................................................................................... 310

4. ........................................ 315
4.1. ............................................................................................ 315
4.2. ............................................................................................ 316
4.2.1. .............................................................................. 317
4.2.2. ................................................................................... 332
4.2.3. .............................................................................................. 339
4.2.4. , .................................................................. 340
4.3. ........................................................................ 343
4.3.1. ...................................................................... 347
4.3.2. ............................................................... 350
4.3.3. .......................................................................... 353
4.4. ............................................................................................. 356
4.4.1. ................................................................... 356
4.4.2. ............................................... 360
4.4.3. ............................................................................................... 367
4.4.4. .................................................................................... 370
4.4.5. ............................................................................................... 376
4.4.6. .................................................................... 377
4.5. ................................................................ 379
4.5.1. ........................................................................ 379
4.5.2. ............................................................ 383
VIII

4.5.3. ................................................................... 389


4.5.4. ........................................................ 391
4.5.5. ............................................................................... 396
4.6. ........................................................................................................ 397
4.6.1. e-mail ................................................................................. 397
4.6.2. ICQ .................................................................................... 400

.................................................................................................................. 404

.......................................................................................................... 405

1. CSS ...................................................................... 407

2. - .............................................................. 421

.............................................................................................. 423


,
HTML, JavaScript
PHP.
,
, -
AJAX, c Web-,
. Gmail, Google Maps, Google Suggest
Web-, -
. Web- -
,
. AJAX
, .

.
, ? .
- ,
AJAX, -
.
, , , . .
JavaScript?
JavaScript, PHP.
, ,
-.

.
, .
, .
2


, , ,
.
,
Web-.
1 " Web-" -
Web-: HTML, HTML (DHTML)
JavaScript, SQL.
SQL, Web- MySQL phpAdmin, PHP
MySQL. -
Windows-
.
2 " AJAX" AJAX -
xajax jQuery. -
AJAX c -
xajax, jQuery PHP.

" ", -
, , -
,
. "Xajax Smarty" -
Smarty -
:
.
-
-.
3 " "
, -
-,
.
4 " "
.
1 . 2
-, .
3


, -
( ) .
"-", -
, ,
.
, , ,
, , .
,
victoruni@km.ru, kmvnews@bk.ru
http://goodtovars.ru/blog, -
.
I

Web-
1


Web-
Web HTML -
, .
HTML, HTML (DHTML)
Web- -
.
JavaScript VBScript,
JavaScript.
- Web- ( ,
,
. .) .

. PHP
. Web-
.
MySQL. -
, .

1.1. HTML CSS


"" HTML. HTML
: .
, , , -
Web-. Web-, ,
HTML-. HTML-
-
HTML- .

1.1.1.
HTML- , -
.
,
. <,
8 I. Web-

, .
>. , -
.
, <>
</>, :
<TABLE>. . .</TABLE>
<FORM>. . .</FORM>
, -
.
, , -
.
, :
<P> ;
<HR> ;
<IMG> .

1.1.2. HTML
HTML , , -
, , , , . -
.
( ), . ,
, .
( ). -
HTML , . . -
<Table>, <TABLE>, <table>. HTML -
HTML 4.01. ,
.

1.1.3. HTML
, HTML,
:
,
HTML (, HTML, HEAD, BODY, TITLE);
(-
, DIV, H1, H2, PRE);
(EM, STRONG) (I, B, U);
(BR, HR), A, -
(IMG, EMBED, OBJECT), (INPUT, SELECT, TEXTAREA),
(TABLE, TR, TD) .
1. Web- 9

1.1.4.
, , , -
:
<H1 id="zagolovok" color="red" ></H1>
> -
=. .
,
. -
.
, .

1.1.5. CSS
() (CSS) , -
HTML .
, HTML, -
HTML- . -
:
background-color : green
font-size: 12 pt

1.1.5.1.
HTML style:
<div style="font-size:12pt;color:green;background-color:yellow">
HTML.
,
-
. , -
CSS, ,
.
1.1.5.2.
, -
:
{ font-family:Arial; background-color:yellow }
{visibility:hidden}
:
span {color:red;font-style:italic}
div.p {text-size:12 px; margin-left: 10 px}
#div1 {border-color:green}
, , .
, , , ,
#, .
10 I. Web-

1.1.5.3.

. ,

. -
. -
, ,
.

.
. HTML-
<style></style>:
<style type="text/css">
<!-- -- >
</style>

<head>
<style="text/css">
h4.style1 {color:red}
#style2 {color:green;background-color:yellow}
</style>
</head>

CSS
class id:
<body>
<h4 class="style1"> 1</h4>
<div id="style2"> 1</div>
</body>

1.1.5.4.

HTML-.
Web- .
, ,
.
, css. CSS-
. HTML-
1. Web- 11

<LINK>,
<HEAD>:
<HEAD>
<LINK type="text/css" href="http://www.my_site.ru/css/
site.css" rel="stylesheet" ">
</HEAD>
:
type="text/css , CSS;
href URL ;
rel="stylesheet" , LINK
.

1.2. JavaScript
JavaScript Web-,
. Web-, -
JavaScript,
. JavaScript Netscape Com-
munications . -
HTML
Web-. JavaScript , -
-. JavaScript
Web-
, HTML,
, . .
JavaScript
.

1.2.1. JavaScript
HTML-. -
<SCRIPT> </SCRIPT>,
HTML- <HEAD> <BODY>.
, <SCRIPT> </SCRIPT>,
.
. -
. <SCRIPT>
:
<SCRIPT language="JavaScript">
<!-- JavaScript -- >
</SCRIPT>
12 I. Web-

HTML-:
( <BODY>),
;
( <HEAD>), -
, -
;
HTML ( < >), -
, <SCRIPT>;
. JavaScript
js, :
<SCRIPT language="JavaScript" src="js/jquery-1.4.2.js">

1.2.2. JavaScript
Web- . -
( ,
.). Web-, -
, .
, .

. , JavaScript,
, :
<input name=input1 type=text onclick="alert(this.value);">
<input name=input2 type=text onchange="function1(this.value)">
. 1.1 HTML,
.
1.1.


HTML-

onAbort IMG
onBlur A, AREA, BUTTON, INPUT, , . .
LABEL, SELECT, TEXTAREA .


onChange INPUT, SELECT, TEXTAREA .

, . . blur
onClick HTML- (
)
onDblClick
1. Web- 13

1.1 ()


HTML-

onError IMG, WINDOW -



onFocus A, AREA, BUTTON, INPUT, (
LABEL, SELECT, TEXTAREA -
)
onKeyDown HTML-

onKeyPress
onKeyUp
onLoad BODY, FRAMESET
onMouseDown HTML-

onMouseMove

onMouseOut -

onMouseOver
onMouseUp -

onMove WINDOW
onReset FORM (
<input type="reset">)
onResize WINDOW
onSelect INPUT, TEXTAREA
onSubmit FORM (
<input type="submit">)
onUnload BODY, FRAMESET -

1.3. HTML
W3C (http://www.w3.org/dom) DHTML -
, -
.
,
. DHTML , -
14 I. Web-

, - Web-, -
. DHTML -
HTML, ,
,
.
JavaScript ,
. ,
-
JavaScript.
(. 1.1). -
,
HTML-,
. window. HTML -
. window
, , -
. window , -
:
, , ,
:
events;
history;
location;
navigator;
screen;
,
, :
document;
frames.
,
DOM (Document Object Model).
, : , , . .
HTML- -

. window.
, , .
,
dot-, . . , -
, :
window.document.forms
//

(). ( 1.1).
1. Web- 15

. 1.1.
16 I. Web-

1.1

window.document.forms[0]
//
window.document.forms.form1
// form1
window.document.forms.form1.elements.elements[1]
// form1
window.document.forms.form1.elements.input1
// input form1

HTML-,
:
window.document.forms.form1.elements.input1.value=" 1";
window.document.forms.form1.elements.input1.style.color="red";
window.document.forms.form1.elements.input1.size=10;
(ID),
ID:
window.document.getElementById("div1").style.display="none";
window.document.getElementById("div1").style.color="green";
dot- window,
.

1.4. PHP

PHP (Hypertext Preprocessor ) -
. PHP
Web-, Web-
. C, Java Perl.
Perl, -
. , PHP , C,
Web-, .
PHP, , , JavaScript, ,
PHP- . PHP -
, -
. , HTML-
.
PHP ,
HTML- .
PHP HTML-,
(JPEG, GIF, PNG), PDF FLASH. PHP -
, XHTML XML.
1. Web- 17

PHP . PHP
, Linux, Unix,
Microsoft Windows, Mac OS . PHP Web-
, , Apache, Microsoft Internet Information Server (IIS), Microsoft
Personal Web Server .
PHP :
CGI.
PHP ODBC : MySQL, MSQL,
Oracle, PostgreSQL, SQLite .
PHP,
MySQL - .
PHP , -
Web-.

1.5. MySQL
Web-
,
: , , , -
. -
SQL-.
, MySQL. MySQL?
, ,
, .

1.5.1.
, MySQL, -
:
;
;
;
;
( ).

1.5.1.1.
:
INT [UNSIGNED]
UNSIGNED ,
( ).
. 1.2.
18 I. Web-

1.2.


TINYINT 128 ... 127
SMALLINT 32 768 ... 32 767
MEDIUMINT 8 388 608 ... 8 388 607
INT 2 147 483 648 ... 2 147 483 647
BIGINT 9 223 372 036 854 775 808 ... 9 223 372 036 854 775 807

1.5.1.2.
MySQL (. 1.3).
:
[(length, decimals)] [UNSIGNED]
:
length ( ),
;
decimals , .

1.3.


UNSIGNED
FLOAT
DOUBLE
REAL DOUBLE
DECIMAL ,
NUMERIC DECIMAL

1.5.1.3.
. -
SELECT , . . ""
"" . ,
,
.
, length , length
1 255:
VARCHAR (length) [BINARY]
1. Web- 19


. BINARY, SELECT
.
. 1.4.
1.4.


VARCHAR 255
TINYTEXT 255
TEXT 65 535
MEDIUMTEXT 16 777 215
LONGTEXT 4 294 967 295

1.5.1.4.
TEXT, -
.
. 1.5.
1.5.


TINYBLOB 255
BLOB 65 535
MEDIUMBLOB 16 777 215
LONGBLOB 4 294 967 295

, -
" ".
1.5.1.5.
MySQL ,
(. 1.6).
1.6.


DATE --
TIME ::
DATETIME -- ::
TIMESTAMP timestamp. -
timestamp,
, -
PHP
20 I. Web-

1.5.2. MySQL
MySQL .
:
:
InnoDB;
BDB.
:
HEAP;
ISAM;
MERGE;
MyISAM.
(Transaction Safe Tables, TST):
. MySQL -
, -
,
.
COMMIT.
ROLLBACK (
).
,
( ).
(Non Transaction Safe Tables,
NTST):
, . . -
.
.
.
MySQL MyISAM.

1.5.3. SQL
SQL -
: , , ,
. . SQL.
CREATE DATABASE :
CREATE DATABASE [IF NOT EXIST] db_name
db_name .
DROP DATABASE db_name , -
; db_name .
1. Web- 21

USE db_name MySQL, ;


db_name .
CREATE TABLE .
:
CREATE TABLE table_name [(create_definitions,)][table_options]

table_name ;
create_definitions , ;
table_options .
:
CREATE TABLE users (
id INT NOT NULL AUTO_INCREMENT, login VARCHAR (32) NOT NULL ,
password VARCHAR (12) NOT NULL , PRIMARY_KEY(id)) TYPE=MyISAM
DROP TABLE :
DROP TABLE table_name1 [,table_name2,.]
table_name1, table_name2 .
INSERT INTO VALUES
:
INSERT INTO table_name VALUES (values1,.)
:
INSERT INTO users VALUES ("1","user1","password1")
:
INSERT INTO users (password,id,login) VALUES ("password2","2","user2").
INSERT INTO SET
:
INSERT INTO table_name SET col_name1=value1[,col_name2=value2]
:
INSERT INTO users SET login="user3"
, , ,
AUTO_INCREMENT , .
DELETE FROM :
DELETE FROM table_name [WHERE definition]
table_name , definition
, .
:
DELETE FROM users WHERE id>3
SELECT .
:
SELECT column1, [FROM table WHERE definition]
[ORDER BY col_name [ASC|DESC],][LIMIT [offset], rows]
22 I. Web-

column ( *). WHERE -


. ORDER BY col_name -
(ASC) (DESC) . LIMIT MySQL
rows , offset.
UPDATE table -
. :
UPDATE table SET col_name1=expr1[,col_name2=expr2]
[WHERE definition]
[LIMIT rows]
SET ,
. WHERE , . LIMIT -
.

1.5.4. PHP MySQL


API MySQL PHP-.

1.5.4.1. mysql_connect
MySQL false
. :
resource mysql_connect([ string $server [, string $username [,string $password]]])
mysql_connect().
(string) , .
$server (), . -
.
$server . -
localhost, PHP;
$username ;
$password .

1.5.4.2. mysql_close
MySQL. :
bool mysql_close ([resource link_identifier])
true , false
. mysql_close() MySQL,
. link_identifier , -
() .
mysql_close() .

1.5.4.3. mysql_select_db
MySQL. :
bool mysql_select_db (string database_name [, resource link_identifier])
1. Web- 23

true , false
. mysql_select_db() -
, . -
, .
,
mysql_connect(), . -
mysql_query() .

1.5.4.4. mysql_query
MySQL. :
resource mysql_query ( string query [, resource link_identifier])
mysql_query() , -
. link_identifier , -
. ,
, mysql_connect()
. . SELECT, SHOW,
EXPLAIN DESCRIBE, mysql_query() ,
false, . , mysql_query() -
true false . ,
false, , , -
. ,
.

1.5.4.5. mysql_fetch_row
.
:
array mysql_fetch_row (resource result)
, , false,
. mysql_fetch_row() , -
. .
. .
mysql_fetch_row()
false, .

1.5.4.6. mysql_fetch_assoc
. -
:
array mysql_fetch_assoc (resource result)
, -
false, . mysql_fetch_assoc()
mysql_fetch_array() ,
MYSQL_ASSOC. .
, ,
24 I. Web-

mysql_fetch_array(). -
,
. , mysql_fetch_assoc() -
, mysql_fetch_row(), .

1.5.4.7. mysql_fetch_array
, , -
. :
array mysql_fetch_array (resource result [, int result_type])
, false,
. mysql_fetch_array()
mysql_fetch_row().
, -
. , mysql_fetch_array() ,
mysql_fetch_row() .

1.5.4.8. mysql_result
. :
mixed mysql_result (resource result, int row [, mixed field])
mysql_result() . -
, ,
(tablename.fieldname). ,
, .
, -
mysql_result(). mysql_result()
, .

1.5.4.9. mysql_num_rows
. :
int mysql_num_rows (resource result)
mysql_num_rows() SELECT.

1.5.4.10. mysql_insert_id
ID, INSERT.
:
int mysql_insert_id ([resource link_identifier])
mysql_insert_id() ID, AUTO_INCREMENT
INSERT ,
link_identifier. link_identifier , -
. mysql_insert_id() 0, -
AUTO_INCREMENT.
, , mysql_insert_id() .
1. Web- 25

1.5.5. phpMyAdmin
SQL PHP , -
, -
, MySQL.
Web- MySQL phpMyAdmin.
, PHP,
MySQL, ,
. MySQL SQL,
, . phpMyAdmin
:
;
, , , ;
, , ;
, , ;
SQL-;
;
;
/ ;
.

1.5.5.1. phpMyAdmin
phpMyAdmin (. . 1.6).
http://localhost/Tools/phpMyAdmin/
( ), , . 1.2.
phpMyAdmin.

. 1.2. phpMyAdmin
26 I. Web-

1.5.5.2.
, . 1.2,
. my_test, -
cp1251_general_ci. , -
my_test (. 1.3).

. 1.3. my_test

, my_test.
.

1.5.5.3.
my_test my_table1.
. 1.3: my_table1, 4.
.
.
(. 1.4). , -
. id
AUTO_INCREMENT (. 1.5). . -
my_table1 my_test (. 1.6).
.
1. Web- 27

. 1.4. my_table1

. 1.5. my_table1
28 I. Web-

. 1.6. my_table1

1.5.5.4.
, .
(. 1.7).

. 1.7. my_table1

. id , . . (.
) AUTO_INCREMENT .
1. Web- 29

, .
(. 1.8).

. 1.8. my_table1

1.5.5.5. -

. . 1.6.4
. .

. 1.9.
30 I. Web-

(. 1.9). (. 1.10)
. (. 1.11).
. , . -
. (INSERT, UPDATE
REPLACE) . .

. 1.10.

. 1.11. export_baza_magazin.sql
1. Web- 31

1.6.
, -
. , -
.
,
: MySQL, Apache, PHP . .
, ,
, ,
. , , ,
.
,
.

, , .
:
;
Xampp;
VertrigoServ;
Wamp.
. ,
, .
, , , -
.

1.6.1. ?
Web- ("..w.", "")
, (Apache, PHP, MySQL, Perl . .)
, Web- -
"" () Windows- -
.
Flash-
. ( "") "
", 5,5 .
. : www.denwer.ru.
:
( Flash-).
Apache, SSL, SSI, mod_rewrite, mod_php.
PHP5 GD, MySQL, sqLite.
MySQL5 .
, .
, /home,
. -
32 I. Web-

; -
.
.
phpMyAdmin MySQL Web-.
sendmail SMTP- ( "" localhost:25, -
/tmp EML);
PHP, Perl, Parser . .

1.6.2.

:
1. Denwer 3 (. 1.12).
Denwer 3, ,
, -
(. 1.13).

. 1.12. www.denwer.ru

2. .
, -
(. 1.14).
, .
, , -
: sqLite, iconv, GD2, MySQL MySQLi, PDO. -
(, PostgreSQL, mbstring, PEAR . .) -
.
1. Web- 33

. 1.13.

. 1.14. e-mail

. 1.15.
34 I. Web-

. 1.16. : PHP5

PHP5.
(. . 1.12) PHP5 (. 1.15).
:
PHP5 (. 1.16).

-
(. . 1.13). e-mail (. . 1.14).

, e-mail,
(. 1.17).
(. 1.18) .
.

. 1.17.

. 1.18.
1. Web- 35

1.6.3.
. -
(. 1.19).

. 1.19.

. -
c:\WebServers (. 1.20).
<Enter>.

. 1.20.
36 I. Web-

,
(. 1.21). -
Web-,
" Unix".

. 1.21.

Z (. 1.22), , -
. , , -
. .

. 1.22.
1. Web- 37

.
:
1. .
. -
. ,
, (, -
Perl- , ).
2. . ,
. 1, .
, . -
, -
( , Perl) . ,
Windows ( -
).
1,
(. 1.23).

. 1.23.

, -
(. 1.24).
/denwer/Run.exe, /denwer/Stop.exe, /denwer/Restart.exe.
(. 1.25).
, -
http://localhost. , -
. 1.26.
, PHP5
. .
38 I. Web-

/usr/local/php5/php.ini

, :
extension = _
, ;;,
, -
. !

. 1.24.

. 1.25.
1. Web- 39

. 1.26.

, , -
.
.
PHP5
PEAR PHP. PEAR
bat- /usr/local/php5/go-pear.bat,
. , PEAR , . .
. Perl:
, ,
. -
"" , PEAR, -
/usr/local/php5/pear.bat. , -
, PEAR .
!

1.6.4.

/home , magazin.
magazin www,
. magazin. -
. :
phpMyAdmin;
.
40 I. Web-

. 1.27. phpMyAdmin

. 1.28. magazin
1. Web- 41

. 1.29.

phpMyAdmin,
http://localhost/Tools/phpMyAdmin (. 1.27). -
(magazine) .
(. 1.28).
. SQL
mySQL (. 1.29)
( magazin
- magazin/magazin.sql), . 1.29
. , -
. 1.30. , 13 .
, sql
- \usr\local\mysql5\data -
. . phpMyAdmin, -
magazin book_examples.
c -
/home
book_primers. book_primers www, -
. -
book_primers.
http://magazin.
(. 1.31).
http://book_primers (. 1.32) -
, 2_7 (. 1.33).
42 I. Web-

. 1.30.

. 1.31.
1. Web- 43

. 1.32.

. 1.33. 2_7
2

AJAX

, -
, .
AJAX (Asynchronous JavaScript and XML) -
Web-, Web-, -
, .

2.1. AJAX
AJAX? AJAX -
2005 (Jesse James Garrett) " -
Web-". AJAX , , -
:
DHTML;
" " XMLHttpRequest.
Web- ,
:
, , " Web"-
(, , .). AJAX
, Google
, Gmail, Google maps Google suggest. -
. -
, -
, , "", ,
"Web 2.0".
AJAX- : -
, , JavaScript,
, , PHP.
XMLHttpRequest.

2.1.1.
, Web-
XMLHttpRequest,
2. AJAX 45

. XMLHttpRequest
, .
XMLHttpRequest :
Internet Explorer:
var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP").
:
var xmlHttp = new XMLHttpRequest();
2.1 .

2.1

if (window.XMLHttpRequest)
{
Request = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
try
{
Request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (CatchException)
{
Request = new ActiveXObject("Msxml2.XMLHTTP");
}
}

xmlHttp
XMLHttpRequest, .

2.1.2. XMLHttpRequest
XMLHttpRequest:
onreadystatechange XMLHttpRequest,
,
;
readyState , :
0 ;
1 ;
2 ;
3 , -
;
4 ; ;
responseText ();
46 I. Web-

responseXML , DOM, ;
status ;
statusText .
(readyState),
, -
, , .
XMLHttpRequest:
abort() ;
getAllResponseHeaders() ;
getResponseHeader("_") ;
open ("_","URL", "", "_", "")
.
URL . .
true ( true).
( -
, , . .
);
send("") HTTP ;
setRequestHeader("_","") -
.

2.1.3.
-
AJAX-:
- (, Web-);
URL ;
;
, ;
.
, onchange input1
(value input1) :
<input id=input1 name=input1 value=10 onchange="f_ajax1(this.value) ">
2.2 .

2.2

function SendRequest(arg)
{
// url
var url="file1.php";
2. AJAX 47

//
Request.onreadystatechange = f_answer1;
//
Request.open("post" ,url, true);
//
Request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;
charset=utf-8");
//
Request.send(arg);
}

( 2.3).
:
, xmlHttp.readyState 4;
c xmlHttp.responseText.

2.3

function f_answer1 () {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
alert(response);
}
}

2.1.4.
:
;
XML;
JSON.
, -
, . . . XML -
DOM- HTML. JSON
JavaScript.
( ). -
JSON- ,
JavaScript .
AJAX-,
.
JavaScript . PHP
JavaScript,
PHP-. , xajax,
PHP AJAX-.
48 I. Web-

2.2. xajax
xajax PHP ,
, Web- AJAX-
, HTML, CSS, JavaScript PHP. , -
xajax,
PHP . xajax
AJAX, , 0.5,
PHP- HTML- .
, xajax AJAX-
, JavaScript. xajax -
GNU Lesser General Public License (LGPL)
. -
http://xajaxproject.org. 0.5.

2.2.1. xajax
xajax JavaScript PHP-, -
.
JavaScript, , PHP, -
XMLHttpRequest xajax , -
PHP. -
, xajax XML- PHP-.
XML- , -
JavaScript xajax -
.

2.2.2. xajax
xajax ,
:
XML -
, . xajax -
, JavaScript
, XML.

xajax .
- ,
xajaxResponse, script().
Firefox, Mozilla, Internet Explorer Safari. -
( DOM) innerHTML, xajax
, CSS, -
.
- ,
JavaScript PHP xajax. -
2. AJAX 49

, JavaScript xajax, PHP -


, .
.
javascript xajax.getFormValues(),
xajax:
xajax_processForm(xajax.getFormValues('formId').
input
"checkbox[][]" "name[first]", -
, $_GET.
xajax
JavaScript- ,
DOM.
Xajax , PHP- -
, .
, -
. , , -
. -
, xajax,
. POST-
, GET-.
.
URI, xajax -
URL . xajax
, HTTPS,
HTTP .
Xajax UTF-8, -
.
Xajax , ,
. JavaScript JavaScript-
.
Smarty :
$smarty->assign('xajax_javascript', $xajax->getJavascript()). -
xajax, {$xajax_javascript}.
, xajax , Web--
AJAX- HTML, CSS, JavaScript PHP. -
, xajax,
PHP-
.

2.2.3. xajax
Xajax PHP-, ,
JavaScript PHP-. PHP- -
XML JavaScript. , PHP
50 I. Web-

, AJAX-.
, XML-.
xajax http://xajaxproject.org/en/download/
xajax 0.5 standard. -
(. 2.1).

. 2.1. xajax

. 2.4 ,
xajax.

2.4

<html>
<head>
<?php
//
require_once ("xajax_core/xajax.inc.php");
// xajax-
$xajax = new xajax();
//
$xajax->register(XAJAX_FUNCTION,"Function1");
// xajax
$xajax->processRequest();
2. AJAX 51

function Function1()
{
$objResponse = new xajaxResponse();
//
return $objResponse;
}
?>
<?php
echo $xajax->getJavascript( "" );
?>
</head>
<body>

</body>
</html>

, xajax , -
, xajaxResponse , XML,
JavaScript .
xajax- JavaScript xajax_:
<a 'href=javascript:void();' onclick='xajax_Function1();'></a>

2.2.4. xajaxResponse
xajaxResponse : assign; append; prepend;
replace; remove; create; insert; insertafter; clear; createInput; insertInput;
insertInputAfter; removeHandler; includeScript; script; addEvent; call;
alert; redirect.
.


- Web-
. -
. 2.2.5.

2.2.4.1. assign
HTML-, innerHTML, style . .
$objResponse->assign($sTarget, $sAttribute, $sData)
$sAttribute $sTarget $sData.

// id=div1 <b>New</b>
$objResponse->assign("div1","innerHtml","<b>New</b>");
52 I. Web-

// id=div1
$objResponse->assign("div1","style.color","red");
// id=div1
$objResponse->assign("div1","style.display","block");

2.2.4.2. append
, .
$objResponse->append($sTarget, $sAttribute, $sData) $sData
$sAttribute $sTarget.

// id=div1 HTML
// <U>element</U>
$objResponse->append("div1","innerHtml","<U>element</U>");
// HTML- <b>New</b>,
// <b>New</b><U>element</U>

2.2.4.3. prepend
.
$objResponse->prepend($sTarget, $sAttribute, $sData) $sData
$sAttribute $sTarget.

// id=div1 HTML
// <U>element</U>
$objResponse->append("div1","innerHtml","<U>element</U>");
// HTML- <b>New</b>,
// <U>element</U><b>New</b>

2.2.4.4. replace
, str_replace.
$objResponse->replace($sTarget, $sAttribute, $sSearch, $sData) -
$sSearch $sAttribute $sTarget
$sData.

// id=div1 HTML
// 1 2<br>
$objResponse->replace("div1","innerHtml","1","2<br>");
// HTML- <b>1234512345</b>,
// <b>2<br>23452<br>2345</b>
// php str_replace
2. AJAX 53

2.2.4.5. remove
.
$objResponse->remove($sTarget) $sTarget.

// id=div1
$objResponse->remove("div1");

2.2.4.6. create
.
$objResponse->create($sParent, $sTag, $sId, $sType = "")
$sTag id $sId, $sParent $sType.

// span id=span1 id=div1


$objResponse->create("div1","span","span1");
// div id=div1
// <div id=div1></div> ,
// <div id=div1><span id=span1></span></div>

2.2.4.7. insert
.
$objResponse->insert($sBefore, $sTag, $sId) $sTag
ID $sId $sBefore.

// span id=span1 id=div1


$objResponse->create("div2","span","span1");
// div id=div1
// div id=div2
// <div id=div1><div id=div2></div></div> ,
// <div id=div1><span id=span1></span><div id=div2></div></div>

2.2.4.8. insertAfter
.
$objResponse->insertAfter($sAfter, $sTag, $sId )
$sTag ID $sId $sAfter.

// span id=span1 id=div1


$objResponse->create("div2","span","span1");
54 I. Web-

// div id=div1
// div id=div2
// <div id=div1><div id=div2></div></div> ,
// <div id=div1><div id=div2><span id=span1></span></div></div>

2.2.4.9. clear
.
$objResponse->clear($sTarget, $sAttribute)
$sAttribute $sTarget.

// id=div1
$objResponse->clear("div2","innerHTML");
// color id=div1
$objResponse->clear("div2","color");

2.2.4.10. createInput
.
$objResponse->createInput($sParent, $sType, $sName, $sId) -
HTML- $sParent, $sType,
$sName ID $sId.

// id=form1 input
// id=input2 name=input2
$objResponse->createInput("form1","input","input2","input2");

2.2.4.11. insertInput
.
$objResponse->insertInput($sBefore, $sType, $sName, $sId)
HTML- $sBefore, $sType, $sName ID $sId.

// input
// id=input2 name=input2
// id=input1
$objResponse->insertInput("input1","input","input2","input2");

2.2.4.12. insertInputAfter
.
$objResponse->insertInputAfter($sAfter, $sType, $sName, $sId)
HTML- $sAfter, $sType, $sName
ID $sId.
2. AJAX 55

// input
// id=input2 name=input2
// id=input1
$objResponse->insertInputAfter("input1","input","input2","input2");

2.2.4.13. removeHandler
.
$objResponse->removeHandler($sTarget, $sEvent, $sHandler)
js- $sHandler $sEvent $sTarget.

// fun_over onmouseover
// id=div1
$objResponse->removeHandler("div1","onmouseover","fun_over");

2.2.4.14. includeScript
js-.
$objResponse->includeScript($sPath) js-,
$sPath.

// js-
// , ,
// js- , ,
//
$objResponse->includeScript("js/jquery.fancybox-1.3.0.js");

2.2.4.15. script
js-.
$objResponse->script($sScript) JavaScript,
$sScript.

// js alert c !!!
$objResponse->script("alert('!!!')");
// id=d1
$objResponse->script("document.getElementById('d1').scrollIntoView();");
// id=div1
// ( $objResponse->assign("d1","style.color","red");)
$objResponse->script("document.getElementById('d1').style.color='red';");
56 I. Web-

2.2.4.16. addEvent
event.
$objResponse->event($sTarget, $sEvent, $sScript)
$sEvent, $sTarget $sScript.

// id=div1
// onmouseover
// onmouseout
$objResponse->event("div1","onmouseover","this.style.color='red'");
$objResponse->event("div1","onmouseout","this.style.color='blue'");

2.2.4.17. call
js- .
$objResponse->call($sFunc, $args,...) js- $sFunc -
$args.

// js- my_function("div1",4,10);
$objResponse->all("my_function", "div1",4, 10))

2.2.4.18. alert
.
$objResponse->alert($sMsg) - JavaScript c
$sMsg.

// alert c !!!

$objResponse->script("alert('!!!');");

2.2.4.19. redirect
, , .
$objResponse->redirect($sURL)
$sURL.

//
$objResponse->redirect("http://www.site.ru/register.php");
2. AJAX 57

2.2.5.
xajax
Web- -
response- xajax. -
xajax (response-)
. -
xajax .
- book_ primers/1 -
"" (. . 1.6)
http://book_primers/1.
http://book_primers/1 , . 2.2.
xajaxResponse :
1. :
assign HTML-, innerHTML, style
. .;
append , ;
prepend ;
replace ,
, PHP- str_replace;
remove ;
create ;
insert ;
insertafter ;
clear .
2. :
createInput ;
insertInput ;
insertInputAfter .
3. :
removeHandler ;
includeScript js-;
script js-;
addEvent event;
call js- ;
alert ;
redirect , ,
.
? -
, . 2.3.
58 I. Web-

. 2.2.

. 2.3.
2. AJAX 59

- , assign, ,
. 2.4.
.
. 2.5: span13.
.

. 2.4. assign

. 2.5. assign
60 I. Web-

, remove (. 2.6)
- , span13.
. 2.7
: span13 .

. 2.6. remove

. 2.7. remove
2. AJAX 61

, . ,
xajax. On-line- -
http://goodtovars.ru/stend.

, ,
. ,
, .

2.2.6. xajax
xajax , -
,
, xajax.
2.2.6.1.
xajax:
XAJAX_DEFAULT_CHAR_ENCODING string ( "utf-8")
xajax, xajaxResponse.
;
XAJAX_GET int ( 0) , GET HTTP-
, xajax;
XAJAX_POST int ( 1) xajax POST HTTP-
.

2.2.6.2. xajax
xajax c :
xajax (string $sRequestURL="", string $sWrapperPrefix="xajax_", string
$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, boolean $bDebug=false) -
.
.
:
$sRequestURL string ( URL );
$sWrapperPrefix string ( "xajax_");
$sEncoding string ( );
$bDebug Mode boolean ( false).
setRequestURI (string $sRequestURL) URI,
.
:
$sRequestURL URL ( )
PHP-, xajax.
:
$xajax->setRequestURL("http://www.site.ru");
62 I. Web-

debugOn () (JavaScript alerts)


xajax.
debugOff () (JavaScript alerts) -
xajax.
statusMessagesOn () -
xajax.
statusMessagesOff () -
xajax ( ).
waitCursorOn () (
).
waitCursorOff () .
exitAllowedOn () xajax , -
( ).
exitAllowedOff () xajax ,
.
errorHandlerOn () ,

(JavaScript alerts).
errorHandlerOff () xajax (-
).
setLogFile (string $sFilename) -, -
xajax. ,
- .
:
$xajax->setLogFile("/xajax_logs/errors.log");
setWrapperPrefix ($sPrefix) , -
JavaScript ( "xajax_").
setCharEncoding (string $sEncoding)
HTML, $sEncoding, , -
, . -
, . . ,
XAJAX_DEFAULT_CHAR_ENCODING.
:
$xajax->setCharEncoding("windows-1251");
//:
$xajax->setCharEncoding("utf-8");
registerFunction (mixed $mFunction, string $sRequestType=XAJAX_POST)
PHP- ,
xajax JavaScript. -
, array("myFunctionName",
"myClass", "myMethod").
2. AJAX 63


-
( 4 , &). -
, JavaScript, , -
.

:
$mFunction ,
;
$sRequestType (XAJAX_GET/XAJAX_POST), -
( XAJAX_POST).
:
$xajax->registerFunction("myFunction");
//:
$xajax->registerFunction(array("myFunctionName", &$myObject,
"myMethod"));
registerExternalFunction (mixed $mFunction, string $sIncludeFile,
string $sRequestType=XAJAX_POST) PHP-, -
xajax.
, , -
.
:
$mFunction ,
(. registerFunction() -
);
$sIncludeFile , ;
$sRequestType (XAJAX_GET/XAJAX_POST),
. XAJAX_POST.
:
$xajax->registerExternalFunction("myFunction","myFunction.inc.php",
XAJAX_POST);
registerCatchAllFunction (mixed
$mFunction)
PHP, , xajax ,
JavaScript. JavaScript
xajax.call() . -
. $mFunction , -
(. registerFunction() -
).
:
$xajax->registerCatchAllFunction("myCatchAllFunction");
registerPreFunction (mixed $mFunction) PHP
, xajax . Xajax
64 I. Web-

"-
" , .
, ,
false (boolean), . "-
" , xajax.
:
$mFunction ,
(. registerFunction() -
).
:
xajax->registerPreFunction("myPreFunction").
canProcessRequests () true, xajax -
, false. , .
getRequestMode () (XAJAX_GET
XAJAX_POST) -1, .
processRequests () xajax, -
xajax,
- ( class/object) XML- -
JavaScript. URI URI
,
HTML.
printJavascript (string $sJsURI="", string $sJsFile=NULL, string
$sJsFullFilename=NULL) xajax JavaScript- , -
getJavascript().
HTML-.
:
$sJsURI , xajax. PHP-
, http://www.myserver.com/myfolder/mypage.php
xajax, http://www.myserver.com/anotherfolder,
, xajax ,
PHP-;
$sJsFile / xajax JavaScript,
( xajax_js/xajax.js);
$sJsFullFilename
xajax.js. ,
xajax_js.
getJavascript (string $sJsURI="", string $sJsFile=NULL, string
$sJsFullFilename=NULL) xajax JavaScript,
HTML- . -
, printJavascript().
2. AJAX 65

2.3. xajax
xajax.

2.3.1.
" "
AJAX
.
. -, submit -
, -,
. -
- book_primers/2-1. index.php -
xajax, xajax, , -
JavaScript (xajax_Control, xajax_Result),
xajax . index.php.
HTML- . -
. -
submit ( disable=true). onchange
Form1 xajax- Control, -
(xajax.getFormValues("Form1")).
. -
ERROR, OK.
submit (
disable=true). ,
submit . index.php 2.5.

2.5

<?php
//
require_once ("xajax_core/xajax.inc.php");
//
require_once ("control.php");
require_once ("result.php");
// xajax-
$xajax = new xajax();
//
$xajax->register(XAJAX_FUNCTION,"Control");
$xajax->register(XAJAX_FUNCTION,"Result");
// xajax
$xajax->processRequest();

?>
66 I. Web-

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1251">
<title> 1 ( 2) "XAJAX" </title>
<?php $xajax->printJavascript(''); ?>
</head>
<body>
<div id=header1><b> "XAJAX" ( 2 1)<br>
" "</b></div>
<br>
<!-- -->
<div id='div1'>
<form id='Form1' action='javascript:void(null);' onsubmit='
xajax.$("Button_Form1").disabled=true;
xajax.$("Button_Form1").value="...";
xajax_Result(xajax.getFormValues("Form1"));'>
<table>
<!-- login -->
<tr>
<td> (5-15 ,)</td>
<td><input type='text' name='login' id='login' value=''
onchange='xajax_Control(xajax.getFormValues("Form1"));'></td>
<td><div id='error_login'><font color='red'>no</font></div></td>
</tr>
<!-- password -->
<tr>
<td> (5-15 ,)</td>
<td><input type='password' name='password' id='password'
onchange='xajax_Control(xajax.getFormValues("Form1"));'></td>
<td><div id='error_password'><font color='red'>no</font></div></td>
</tr>
<!-- password -->
<tr>
<td> </td>
<td><input type='password' name='password1' id='password1' value=''
onchange='xajax_Control(xajax.getFormValues("Form1"));'></td>
<td><div id='error_password1'><font color='red'>no</font></div></td>
</tr>
<!-- email -->
<tr>
<td> e-mail</td>
<td><input type='input' name='email' id='email' value=''
2. AJAX 67

onchange='xajax_Control(xajax.getFormValues("Form1"));'></td>
<td><div id='error_email'><font color='red'>no</font></div></td>
</tr>
<!-- submit -->
<tr>
<td></td>
<td><input type='submit' id='Button_Form1' disabled=true
value=' ->' ></td>
<td></td>
</tr>
</table>
</div>
<!-- -->
<div id='result'></div>
</body>
</html>

Control() control.php.
, .
, error (. 2.8).
submit (. 2.9).
control.php 2.6.

. 2.8.

. 2.9.
68 I. Web-

2.6

//
//
function Control($Id)
{
$objResponse = new xajaxResponse();
$count=0;
// login
if(!ereg("^([a-z,A-Z,-,-,0-9]{5,15})$",$Id[login]))
$objResponse->assign("error_login","innerHTML","<font
color='red'>ERROR</font>");
else
{
$objResponse->assign("error_login","innerHTML","<font
color='blue'></font>");
$count++;
}
// password
if(!ereg("^([a-z,A-Z,-,-,0-9]{5,15})$",$Id[password]))
$objResponse->assign("error_password","innerHTML","<font
color='red'>ERROR</font>");
else
{
$objResponse->assign("error_password","innerHTML","<font
color='blue'></font>");
$count++;
}
// password1
if($Id[password1]==$Id[password] && strlen($Id[password1])>0)
{
$objResponse->assign("error_password1","innerHTML","<font
color='blue'></font>");
$count++;
}
elseif(strlen(trim($Id[password1]))==0)
{
$objResponse->assign("error_password1","innerHTML","<font
color='red'>ERROR</font>");
}
else
{
$objResponse->assign("error_password1","innerHTML","<font
color='red'><>password!</font>");
2. AJAX 69

}
// email
if(ereg("^([a-z,0-9,-_\.]{2,20})([\@]{1})([a-z,0-9,-_]
{2,20})([\.]{1})([a-z,]{1,3})$",$Id[email]))
{
$objResponse->assign("error_email","innerHTML","<font
color='blue'></font>");
$count++;
}
else
$objResponse->assign("error_email","innerHTML","<font
color='red'>ERR</font>");
// ?
//
if($count==4)
$objResponse->assign("Button_Form1","disabled",false);
//
else
$objResponse->assign("Button_Form1","disabled",true);

return $objResponse;
}


action . onsubmit.
xajax- Result, result.php.
result (. 2.10). -
, submit .

. 2.10.
70 I. Web-

result.php 2.7.

2.7

function Result($Id)
{
$objResponse = new xajaxResponse();
//
$objResponse->assign("Button_Form1","disabled",true);
$objResponse->assign("Button_Form1","value"," ->");
//
$objResponse->assign("login","value","");
$objResponse->assign("password","value","");
$objResponse->assign("password1","value","");
$objResponse->assign("email","value","");
//
$text1=" <br>";
$text1.=" :<br>";
$text1.=" ".$Id[login]."<br>";
$text1.=" ".$Id[password]."<br>";
$text1.="E-mail ".$Id[email]."<br>";
//
$objResponse->assign("result","innerHTML",$text1);
return $objResponse;
}

, .

2.3.2. select-
-
, -
. ,
www.mail.ru ( > >
).
, . -
- book_primers/2-2.
. , ?
. - -
(www.gnivc.ru)
( ). ,
, ( ), , , , , .
XLS.
2. AJAX 71

( ), , .
24 -
book_primers/2-2/kladr_primer2-2.sql


kladr.sql .
php.ini,
usr/local/php5, upload_max_filesize=8M -
, , upload_max_filesize = 30M. .

primer_kladr:
id ;
id_region ID ;
id_rayon ID ;
id_town ID ;
id_punkt ID ;
name ;
socr (, , .);
zindex .
primer_kladr 2.8.

2.8

CREATE TABLE 'book_xajax1'.'primer_kladr' (


'id' bigint( 12 ) NOT NULL AUTO_INCREMENT ,
'id_region' int( 2 ) NOT NULL default '0',
'id_rayon' int( 3 ) NOT NULL default '0',
'id_town' int( 3 ) NOT NULL default '0',
'id_punkt' int( 3 ) NOT NULL default '0',
'name' varchar( 100 ) CHARACTER SET cp1251 default NULL ,
'socr' varchar( 10 ) CHARACTER SET cp1251 default NULL ,
'zindex' int( 6 ) default NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

primer_kladr -
. index.php

. .
onchange xajax- Select_Region -
. select , -
. , ( " "),
.
number, select, . -
index.php 2.9.
72 I. Web-

2.9

<?php
//
require_once ("xajax_core/xajax.inc.php");
//
require_once ("select_region.php");
require_once ("result_select.php");
// xajax-
$xajax = new xajax();
//
$xajax->register(XAJAX_FUNCTION,"Select_Region");
$xajax->register(XAJAX_FUNCTION,"Result_Select");
// xajax
$xajax->processRequest();
//
require_once("mybaza.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1251">
<title> 1 ( 2) "XAJAX" </title>
<?php $xajax->printJavascript(''); ?>

</head>
<body>
<!-- -->
<div id=header1><b> "XAJAX" ( 2 1)<br>
select- </b></div>
<br>
<!-- -->
<form id='FormSelectRegion' method='post' action='javascript:void(null);'
onsubmit='
xajax.$("ButtonFormSelectRegion").disabled=true;
xajax.$("ButtonFormSelectRegion").value="...";
xajax_Result_Select(document.getElementById("vibor").value);'
enctype="multipart/form-data";>
<input type='hidden' id='number' name='number' value='0'><br>
<input type='hidden' id='vibor' name='vibor' value='0'><br>
<b> </b><br>
<div id='divselectregion1'>
2. AJAX 73

<select name=selectregion1 id='selectregion1' onchange='


document.getElementById("number").value=1;
xajax_Select_Region(xajax.getFormValues("FormSelectRegion"));'>
<option value="0">
<?php
//
$query1="SELECT id,name,socr FROM ".TABLE1." WHERE id_rayon=0 &&
id_town=0 && id_punkt=0 ORDER BY id ASC";
$rez1=mysql_query($query1);
while($row1=mysql_fetch_row($rez1))
$text1.="<option value=".$row1[0]." >".$row1[1]." ".$row1[2];
$text1.="</select></div>";
$text1.="<div id='divselectregion2'></div>";
$text1.="<div id='divselectregion3'></div>";
$text1.="<div id='divselectregion4'></div>";
echo $text1;
?>
<input type='submit' id='ButtonFormSelectRegion' value=''
disabled=true>
</form>
<! -->
<div id='div_result'></div>
</body>
</html>

. 2.11. select

Select_Region, select_region.php,
FormSelectRegion number -
. -
select: ; -
, ; ,
( ). select -
(. 2.11).
vibor, , . -
74 I. Web-

, -
vibor .
select_region.php 2.10.

2.10

<?php
function Select_Region($Id)
{
$objResponse = new xajaxResponse();
require_once("mybaza.php");

switch($Id[number])
{
case 1:
$objResponse->assign("vibor","value",$Id[selectregion1]);
if($Id[selectregion1]>0)
{
$query1="SELECT name,socr FROM ".TABLE1." WHERE
id=".$Id[selectregion1]." ";
$text1=mysql_result(mysql_query($query1),0,"name")." ";
$text1.=mysql_result(mysql_query($query1),0,"socr");
$text2="<select name=selectregion2 id='selectregion2'
onchange='
document.getElementById(\"number\").value=2;
xajax_Select_Region(xajax.getFormValues
(\"FormSelectRegion\"));'>";
$text2.="<option value='0' selected> , ";
$objResponse->assign("vibor","value","0");
$query2="SELECT id,name,socr,id_rayon FROM ".TABLE1."
WHERE id_punkt=0
&& id_region=".substr($Id[selectregion1],1,2)."
&& (id_rayon=0 || id_town=0) && (id_rayon>0 || id_town>0)
ORDER BY id ASC";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_row($rez2))
{
if($row2[3]>0)
$text2.="<option value=".$row2[0]." >".$row2[1]."
".$row2[2];
else
$text2.="<option value=".$row2[0]." >".$row2[2]."
".$row2[1];
}
2. AJAX 75

$text2.="</select>";
$objResponse->assign("divselectregion2","innerHTML",$text2);
$objResponse->assign("divselectregion3","innerHTML",
"<table></table>");
$objResponse->assign("divselectregion4","innerHTML",
"<table></table>");
$objResponse->assign("ButtonFormSelectRegion","disabled",
true);
}
else //
{
$objResponse->assign("vibor","value","0");
$objResponse->assign
("divselectregion2","innerHTML","<table></table>");
$objResponse->assign
("divselectregion3","innerHTML","<table></table>");
$objResponse->assign
("divselectregion4","innerHTML","<table></table>");
$objResponse->assign
("ButtonFormSelectRegion","disabled",true);
}
break;
case 2:
$objResponse->assign("vibor","value",$Id[selectregion2]);
if($Id[selectregion2]>0)
{
if(substr($Id[selectregion2],3,3)<>"000") //
{
$text2="<select name=selectregion3 id='selectregion3'
onchange='
document.getElementById(\"number\").value=3;
xajax_Select_Region(xajax.getFormValues
(\"FormSelectRegion\"));'>";
$objResponse->assign("vibor","value","0");
$text2.="<option value='0' selected> .";
$query2="SELECT id,name,socr FROM ".TABLE1." WHERE
id_region=".substr($Id[selectregion2],1,2)."
&& id_rayon=".substr($Id[selectregion2],3,3)."
&& (id_punkt>0 || id_town>0)
ORDER BY id ASC ";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_row($rez2))
{
$text2.="<option value=".$row2[0].">".$row2[2]."
76 I. Web-

".$row2[1];
}
$text2.="</select>";
$objResponse->assign
("divselectregion3","innerHTML",$text2);
$objResponse->assign
("divselectregion4","innerHTML","<table></table>");
$objResponse->assign
("ButtonFormSelectRegion","disabled",true);
}
else //
{
$query2="SELECT id,name,socr FROM ".TABLE1." WHERE
id_region=".substr($Id[selectregion2],1,2)."
&& id_rayon=0
&& id_town=".substr($Id[selectregion2],6,3)."
ORDER BY id ASC";
$rez2=mysql_query($query2);
if(mysql_num_rows($rez2)==1) //
{
$objResponse->assign
("ButtonFormSelectRegion","disabled",false);
$objResponse->assign
("divselectregion3","innerHTML","<table></table>");
$objResponse->assign
("divselectregion4","innerHTML","<table></table>");
}
else
{
$text2="<select name=selectregion3 id='selectregion3'
onchange='
document.getElementById(\"number\").value=3;
xajax_Select_Region(xajax.getFormValues
(\"FormSelectRegion\"));'>";
$objResponse->assign("vibor","value","0");
$text2.="<option value='0' selected> ";
while($row2=mysql_fetch_row($rez2))
{
$text2.="<option value=".$row2[0].">".$row2[2]."
".$row2[1];
}
$text2.="</select>";
$objResponse->assign
("ButtonFormSelectRegion","disabled",true);
2. AJAX 77

$objResponse->assign
("divselectregion3","innerHTML",$text2);
$objResponse->assign
("divselectregion4","innerHTML","<table></table>");
}
}
}
else //
{
$objResponse->assign
("ButtonFormSelectRegion","disabled",true);
$objResponse->assign("vibor","value","0");
$objResponse->assign
("divselectregion3","innerHTML","<table></table>");
$objResponse->assign
("divselectregion4","innerHTML","<table></table>");
}
break;
case 3:
if($Id[selectregion3]>0)
{
$objResponse->assign
("ButtonFormSelectRegion","disabled",false);
$objResponse->assign("vibor","value",$Id[selectregion3]);
$objResponse->assign
("divselectregion4","innerHTML","<table></table>");
}
else
{
$objResponse->assign("ButtonFormSelectRegion","disabled",true);
$objResponse->assign("vibor","value","0");
$objResponse->assign
("divselectregion4","innerHTML","<table></table>");
}
default: break;
}
return $objResponse;
}
?>

xajax- Re-
sult_Select. vibor.

(. 2.12). Result_Select result_select.php
78 I. Web-

( 2.11). -
www.bazakatalogov.ru.

. 2.12.

2.11

<?php
function Result_Select($Id)
{
$objResponse = new xajaxResponse();
require_once("mybaza.php");

$text=" :<br>";
$text.=" ".$Id."<br>";
$id_region=substr($Id,1,2);
$id_rayon=substr($Id,3,3);
$id_town=substr($Id,6,3);
$id_punkt=substr($Id,9,3);
//
$query1="SELECT name,socr FROM ".TABLE1." WHERE
id_region='".$id_region."' ";
$text.=mysql_result(mysql_query($query1),0,"name");
$text.=" ".mysql_result(mysql_query($query1),0,"socr");
//
if($id_rayon>0)
{
$query1="SELECT name,socr FROM ".TABLE1." WHERE
id_region='".$id_region."' && id_rayon='".$id_rayon."' ";
2. AJAX 79

$text.=" --> <br>".mysql_result(mysql_query($query1),0,"name");


$text.=" ".mysql_result(mysql_query($query1),0,"socr");
}
//
if($id_town>0)
{
$query1="SELECT name,socr FROM ".TABLE1." WHERE
id_region='".$id_region."' && id_rayon='".$id_rayon."'
&& id_town='".$id_town."' ";
$text.=" --> <br>".mysql_result(mysql_query($query1),0,"socr");
$text.=" ".mysql_result(mysql_query($query1),0,"name");
}
// .
if($id_punkt>0)
{
$query1="SELECT name,socr FROM ".TABLE1." WHERE
id_region='".$id_region."' && id_rayon='".$id_rayon."'
&& id_town='".$id_town."' && id_punkt='".$id_punkt."' ";
$text.=" --> <br>".mysql_result(mysql_query($query1),0,"socr");
$text.=" ".mysql_result(mysql_query($query1),0,"name");
}

$objResponse->assign("div_result","innerHTML",$text);
$objResponse->assign("ButtonFormSelectRegion","value","");
$objResponse->assign("ButtonFormSelectRegion","disabled",false);

return $objResponse;
}
?>

2.3.3.
, , -
. ,
.
. -
, MySQL. -
- book_primers/2-3.
primer_katalog.
2.12.
primer_katalog:
id ;
id_parent ID ;
80 I. Web-

name ();
type (, ).

2.12

CREATE TABLE 'book_xajax1'.'primer_katalog' (


'id' int( 5 ) NOT NULL AUTO_INCREMENT ,
'id_parent' int( 5 ) NOT NULL default '0',
'name' varchar( 30 ) NOT NULL default '',
'type' set( 'tovar', 'kategory' ) NOT NULL default 'kategory',
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

primer_katalog -
. index.php .
id_parent=0.
id=menu.$id, .$id ID .
, .
( open_dir.ico,
close_dir.ico). xajax-
Open_Kategory Close_Kategory .
index.php 2.13.

2.13

<?php
//
require_once ("xajax_core/xajax.inc.php");
//
require_once ("open_kategory.php");
require_once ("close_kategory.php");
// xajax-
$xajax = new xajax();
//
$xajax->register(XAJAX_FUNCTION,"Open_Kategory");
$xajax->register(XAJAX_FUNCTION,"Close_Kategory");
// xajax
$xajax->processRequest();
//
require_once("mybaza.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
2. AJAX 81

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">


<title> 3 ( 2) "XAJAX" </title>

<?php $xajax->printJavascript(''); ?>

<style type="text/css">
img { border-style: none }
div.menu { margin-left:16px;font-size:small;
vertical-align:center }
</style>
</head>
<body>
<!-- -->
<div id=header1><b> "XAJAX" ( 2 3)<br>
</b></div>
<br>
<div id=menu0 class=menu>
<!-- -->
<?php
$text1="";
$query1="SELECT * FROM ".TABLE1." WHERE id_parent=0
ORDER BY id ASC";
$rez1=mysql_query($query1);
while($row1=mysql_fetch_assoc($rez1))
{
if($row1[type]=='kategory')
$text1.="<div class='menu' id='menu".$row1[id]."'>
<a href='javascript:void();' onclick='
xajax_Open_Kategory(".$row1[id].")'>
<img src='open_dir.ico'></a>&nbsp&nbsp&nbsp"
.$row1[name]."</div>";
else
$text1.="<div class='menu' id='menu".$row1[id]."'>
<a href='javascript:void();' onclick=''>
<img src='tovar.ico'></a>&nbsp&nbsp&nbsp"
.$row1[name]."</div>";
}
echo $text1;
?>
</div>
</body>
</html>

Open_Kategory, open_kategory.php (-
2.14), .
82 I. Web-

ID .
id_parent, ID .
.

2.14

<?php
function Open_Kategory($Id)
{
$objResponse = new xajaxResponse();

require_once("mybaza.php");
$text1="";
//
$query0="SELECT * FROM ".TABLE1." WHERE id='".$Id."' ";
$rez0=mysql_query($query0);
$row0=mysql_fetch_assoc($rez0);
$text1.="<a href='javascript:void();' onclick='
xajax_Close_Kategory(".$Id.")'>
<img src='close_dir.ico'></a>&nbsp&nbsp&nbsp
".$row0[name]."</a>";
//
$query1="SELECT * FROM ".TABLE1." WHERE id_parent='".$Id."' ";
$rez1=mysql_query($query1);
while($row1=mysql_fetch_assoc($rez1))
{
if($row1[type]=='kategory')
$text1.="<div class='menu' id='menu".$row1[id]."'>
<a href='javascript:void();' onclick='
xajax_Open_Kategory(".$row1[id].")'>
<img src='open_dir.ico'></a>&nbsp&nbsp&nbsp"
.$row1[name]."</div>";
else
$text1.="<div class='menu' id='menu".$row1[id]."'>
<a href='javascript:void();' onclick=''>
<img src='tovar.ico'></a>&nbsp&nbsp&nbsp"
.$row1[name]."</div>";
}
$objResponse->assign("menu".$Id,"innerHTML",$text1);
return $objResponse;
}
?>

Close_Kategory, close_kategory.php
( 2.15), . -
2. AJAX 83

. -
. . 2.13.

. 2.13 16 px
.
div.menu {margin-left:16px}.

2.15

<?php
function Close_Kategory($Id)
{
$objResponse = new xajaxResponse();

require_once("mybaza.php");
$text1="";
//
$query1="SELECT * FROM ".TABLE1." WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<a href='javascript:void();' onclick='
xajax_Open_Kategory(".$Id.")'>
<img src='open_dir.ico'></a>&nbsp&nbsp&nbsp
".$row1[name]."</a>";
$objResponse->assign("menu".$Id,"innerHTML",$text1);
return $objResponse;
}

?>

. 2.13.
84 I. Web-

2.3.4.

( )
. .
.
.
. -
- book_primers/2-4. index.php -
. . 2.14.
index.php 2.16.
.
, option -
, ;. input
id=name1. id=name2, name3 . .
,
ID.
input id=counted. -
,
xajax- Delete_Input.

. 2.14.
2. AJAX 85

2.16

<?php
//
require_once ("xajax_core/xajax.inc.php");
//
require_once ("add_input.php");
require_once ("delete_input.php");
require_once ("new_path.php");
require_once ("result.php");
// xajax-
$xajax = new xajax();
//
$xajax->register(XAJAX_FUNCTION,"Add_Input");
$xajax->register(XAJAX_FUNCTION,"Delete_Input");
$xajax->register(XAJAX_FUNCTION,"New_Path");
$xajax->register(XAJAX_FUNCTION,"Result");
// xajax
$xajax->processRequest();
//
require_once("mybaza.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title> 4 ( 2) "XAJAX" </title>

<?php $xajax->printJavascript(''); ?>


</head>
<body>
<!-- -->
<div id=header1><b> "XAJAX" ( 2 4)<br>
</b></div>
<br>
<!-- -->
<div id='div1'>
<form id='Form1' action='javascript:void(null);' onsubmit='
xajax.$("Button_Form1").disabled=true;
xajax.$("Button_Form1").value="...";
xajax_Result(xajax.getFormValues("Form1"));'>
<table>
<!-- -->

<?php
86 I. Web-

echo date('Y-m-d',strtotime("today + 1 day"));


?>
<br>
<select name='select_path' id='select_path'
onchange='xajax_New_Path(xajax.getFormValues("Form1"));'>
<option value="550;" selected> 650 .
<option value="700;"> 700 .
<option value="400; "> 400 .
<option value="650;"> 650 .
<option value="450; "> 450 .
</select>
<br><br>
<!-- -->
<input type='hidden' name='count' id='count' value='1'>
<input type='hidden' name='pay' id='pay' value='650'>
<input type='hidden' name='countid' id='countid' value='1'>
<input type='hidden' name='delete' id='delete' value='0'>
<!-- -->
(.)
<div name='pay1' id='pay1'>650</div>
-
<div name='people' id='people'>1</div>
(.)
<div name='payall' id='payall'>650</div>
<br>
<input type='text' name='phone' id='phone'
size=12 maxlength=12><br><br>
<!-- -->
( 1 ): <br>
<br>
<input type='text' name='name1' id='name1'
value=' ' size=50 maxlength=50><br><br>
<!-- -->
<a href='javascript:void();' onclick='
xajax_Add_Input(xajax.getFormValues("Form1"));'>
</a>
<br><br>
<input type='submit' id='Button_Form1'
value=' ->' >
</div>
<div id='result'>
</div>
</body>
</html>
2. AJAX 87

. 2.15. input

, xajax-
Add_Input, add_input.php ( 2.17). -
input response- insertInputAfter. -
<br> <span>, <span> -
input .
. 2.15.

<span> <br> ID, -
.

2.17

<?php
function Add_Input($Id)
{
$objResponse = new xajaxResponse();
// input
$countid=$Id[countid]+1;
88 I. Web-

$objResponse->insertInputAfter
("name1","input","name".$countid,"name".$countid);
// <br>
$objResponse->insertAfter("name1","br","br".$countid);
//
$objResponse->assign("name".$countid,"size","50");
$objResponse->assign("name".$countid,"value"," ");
// <span>
$objResponse->insertAfter("name".$countid,"span","span".$countid);
//
$a="<a href='javascript:void();'
onclick='document.getElementById(\"delete\").value=".$countid.";
xajax_Delete_Input(xajax.getFormValues(\"Form1\"))'></a>";
$objResponse->assign("span".$countid,"innerHTML",$a);
// countid
$objResponse->assign("countid","value",$countid);
// count
$objResponse->assign("count","value",$Id[count]+1);
//
//$pay1=substr($Id[select_path],0,strpos($Id[select_path],";"));
// , -,
$objResponse->assign("pay1","innerHTML",$Id[pay]);
$objResponse->assign("people","innerHTML",$Id[count]+1);
$objResponse->assign("payall","innerHTML",$Id[pay]*($Id[count]+1));

return $objResponse;
}
?>

, xajax- Delete_Input, -
delete_input.php ( 2.18). in-
put response- remove.
input, <br> <span>, .


Delete_Input, -
delete ID input.

2.18

<?php
function Delete_Input($Id)
{
2. AJAX 89

$objResponse = new xajaxResponse();


// input
$objResponse->remove("name".$Id[delete]);
//
$objResponse->remove("span".$Id[delete]);
// br
$objResponse->remove("br".$Id[delete]);
// count
$objResponse->assign("count","value",$Id[count]-1);
//
$pay1=substr($Id[select_path],0,strpos($Id[select_path],";"));
// , -,
$objResponse->assign("pay1","innerHTML",$pay1);
$objResponse->assign("people","innerHTML",$Id[count]-1);
$objResponse->assign("payall","innerHTML",$pay1*($Id[count]-1));

return $objResponse;
}
?>

onchange xajax-
New_Path, new_path.php ( 2.19). -
. xajax-
. 2.16.

2.19

<?php
function New_Path($Id)
{
$objResponse = new xajaxResponse();
//
$pay1=substr($Id[select_path],0,strpos($Id[select_path],";"));
// pay
$objResponse->assign("pay","value",$pay1);
// , -,
$objResponse->assign("pay1","innerHTML",$pay1);
$objResponse->assign("people","innerHTML",$Id[count]);
$objResponse->assign("payall","innerHTML",$pay1*$Id[count]);

return $objResponse;
}
?>
90 I. Web-

. 2.16.

. 2.17.
2. AJAX 91

xajax- Result, -
result.php, . -
,
result (. 2.17). -
result.php 2.20.

JavaScript-
scrollIntoView(). response- script.

2.20

<?php
function Result($Id)
{
$objResponse = new xajaxResponse();
$text="";
$text=" <br>";
//
$pay=substr($Id[select_path],0,strpos($Id[select_path],";"));
$path=str_replace($pay.";","",$Id[select_path]);
$text.=" ".$path."<br>";
$text.=" ".$Id[pay]." . <br>";
//
$text.=" ".$Id[count]." <br>";
$text.=" : <br>";
for($i=1,$j=1;$i<=$Id[countid];$i++)
{
if(isset($Id['name'.$i]))
{
$text.=$j.". ".$Id['name'.$i]."<br>";
$j++;
}
}
//
$text.="<br> ".$Id[pay]*$Id[count]." . <br>";
//
$text.="<br>
".$Id[phone];
// result
$objResponse->assign("result","innerHTML",$text);
//
92 I. Web-

$objResponse->assign("Button_Form1","value"," ->");
$objResponse->assign("Button_Form1","disabled",false);
//
$objResponse->script("document.getElementById
('result').scrollIntoView();");

return $objResponse;
}
?>

2.4. jQuery
jQuery? jQuery JavaScript-, -
2006 . : "jQuery is designed to change the way
that you write JavaScript". ,
: "jQuery , ,
JavaScript". jQuery (
) (DOM), -
DOM . -
, - CSS1, CSS2 XPath,
, , .
jQuery API ( )
AJAX.
http://jquery.com. 1.4.2.
, , -
(
), -
.

2.4.1. jQuery
:
DOM;
;
;
AJAX-;
JavaScript-.
jQuery ,
. ,
jQuery , , -
. -
.
JavaScript-, .
2. AJAX 93

2.4.2. jQuery
jQuery http://docs.jquery.com/
Downloading_jQuery Uncompressed.
(. 2.18) -
.

. 2.18. jQuery

jQuery, , Web- JavaScript-


:
<head>
<script type="text/javascript" src="js/jQuery-1.4.2.js"></script>
</head>
jQuery :
jQuery- $();
$.

2.4.2.1. $
jQuery $.
JavaScript-, $
, jQuery.
, ,
:
jQuery(function($)
{
// , $ jQuery
})
94 I. Web-

, , -
, jQuery- ( ).
( , -
AJAX) ,
, . jQuery
CSS Xpath.
CSS, -
Xpath.
2.4.2.2.
, ,
CSS, . . CSS jQuery.
CSS . 2.1.
2.1. CSS


* , n- -

E E
E:nth- , n- -
child(n)
E:first-child ,

E:last-child ,

E:only-child E, -

E:empty E, ( )
E:enabled
E:disabled
E:checked (,
)
E.warning E warning (class="warning")
E#myid E ID, "myid" ( )
E:not(s) E, s
E F F, E
E > F F, E
E + F F, E
E ~ F F, E
E,F,G E, F G
2. AJAX 95

$('#element1');
// id=element1
$('.class1');
// class=class1
$('div#element1');
// div id=element1
$('div.class1');
// div class=class1
$('div span');
// span div
$('div > a');
// a div, span
// div
$('div, a');
// div a
$('a + img');
// img , a
$('a ~ img');
// img a

. 2.2. XPath,
. . @.
2.2. jQuery


E[@foo] E "foo"
E[@foo=bar] E, "foo" "bar"
E[@foo^=bar] E, "foo" "bar"
E[@foo$=bar] E, "foo" "bar"
E[@foo*=bar] E, "foo" "bar"

jQuery (. 2.3), -
.
2.3. c jQuery


:even
:odd
:eq(N) :nth(N) N
96 I. Web-

2.3 ()


:gt(N) , N
:lt(N) , N
:first
:last
:parent , (
)
:contains('test') ,
:visible (
"display", "block" "inline", "visibility",
"visible", ,
"hidden")
:hidden (
"display", "none")

$('div:even');
// div
$('div:odd');
// div
$('div:eq(N)');
// div, N DOM
$('div:gt(N)');
// div, , N DOM
$('div:lt(N)');
// div, , N DOM
$('div:contains(text)');
// div,
$('div:empty');

,
(enabled/disabled/selected/
checked) (. 2.4).
2.4.


:input (input, select, textarea, button)
:text (type="text")
:password (type="password")
2. AJAX 97

2.4 ()


:radio (type="radio")
:checkbox (type="checkbox")
:submit (type="submit")
:image (type="image")
:reset (type="reset")
:button (type="button")

$(":text");
// input- =text
$(":radio");
// input- =radio
$("input:enabled");
// input
$("input:checked");
//

2.4.2.3. jQuery
jQuery
:
append(content) -
;
prepend(content)
;
appendTo(expr) ;
prependTo(expr) ;
attr(name) ;
attr(params) ;
{1:1[, 2:2[, ]]};
attr(name, value) ;
css(name) / CSS;
css(params) CSS;
css(name, value) CSS;
text() ;
text(val) ;
98 I. Web-

html() HTML- ;
html(val) HTML- ;
empty() .

$("<b></b>").appendTo($("#div1"));
// <b></b> id=div1
$(#div1).empty();
// id=div1
$(#div1).prepend("<b></b>");
// <b></b> id=div1
$("#div1").css({backgroundColor: "#F00",color: "#00F"});
// id=div1

jQuery
. , ,
.

// <select id="select1">...</select>
var sel = $("select1");
// <option value="1"> </option>
$("<option></option>")
//
.attr("value", 1)
//
.html(" ")
//
.appendTo(sel);
//

, ,
, .
2.4.2.4. jQuery
, jQuery, . 2.5.
2.5. jQuery


blur() blur
blur() blur

2. AJAX 99

2.5 ()


change() change
change() change

click() click
click() click

dblclick() dblclick
dblclick() dblclick -

error() error
error() error

focus() focus
focus() focus

keydown() keydown
keydown() keydown

keypress() keypress
keypress() keypress -

keyup() keyup
keyup() keyup

load() load -

mousedown() mousedown -

mouseenter() mouseenter -

mouseleave() mouseleave -

mousemove() mousemove -

mouseout() mouseout -

100 I. Web-

2.5 ()


mouseover() mouseover -

mouseup() mouseup

resize() resize

scroll() scroll

select() select
select() select

submit() submit
submit() submit

unload() unload

2.4.2.5. jQuery
-
JavaScript- ,
Flash.
, (
, ), (,
, ).
jQuery :
show([speed[, callback]]) ;
hide([speed[, callback]]) ;
fadeIn(speed[, callback]) -
;
fadeOut(speed[, callback]) -
;
slideDown(speed, callback) , ;
slideUp(speed, callback) , .
speed "slow" (600 )
"fast" (200 ); callback , -
.
2. AJAX 101

2.4.3. PHP jQuery


jQuery
. JavaScript .
AJAX JQuery , . .
JavaScript- . PHP-
, -
jQuery . -
xajax. xajax jQuery.

2.4.3.1. jQuery Carousel


-
jQuery.
AJAX, xajax. -
book_primers/2-5. http:// book_
primers/2-5 ( ). ,
. 2.19.

. 2.19. 2-5

js jCarousel
jCarousel ( xajax- 1). -
, . 2.20.

. 2.20. js jCarousel
102 I. Web-

. 2.21. jCarousel

. 2.22. jCarousel


( xajax- 2). . 2.21.
( xajax-
2). . 2.22.
index.php 2.21.
xajax- Plugin, plugin.php ( 2.22).

2.21

<?php
require_once ("xajax_core/xajax.inc.php");
require_once ("plugin.php");
2. AJAX 103

$xajax = new xajax();


//
$xajax->register(XAJAX_FUNCTION,"Plugin");
$xajax->processRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<link rel="stylesheet" type="text/css" href="js/skins/tango/skin.css" />
<title> 1 ( 2) </title>
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<?php $xajax->printJavascript(''); ?>
</head>
<body>
<!-- -->
<div id=header1><b> ( 2 5)<br>
jQuery (jCarousel)</b></div>
<br>
<!-- -->
<div id='div0'>
<a href='javascript:void();' onclick='xajax_Plugin(1);'>
js- jCarousel</a>
</div>
<div id='div1'><!-- -->
</div>
</body>
</html>

2.22

<?php
// jQuery
function Plugin($Id)
{
$objResponse = new xajaxResponse();

switch($Id)
{
case 1:
$objResponse->includeScript("js/jquery.jcarousel.js");
$text="<a href='javascript:void();'
onclick='xajax_Plugin(2);'>
</a>";
104 I. Web-

$objResponse->assign("div0","innerHTML",$text);
break;
case 2:
$text1="
<ul id='mycarousel' class='jcarousel-skin-tango'>
<li><img src='img/img1.gif' /></li>
<li><img src='img/img2.gif' /></li>
<li><img src='img/img3.gif' /></li>
<li><img src='img/img4.gif' /></li>
<li><img src='img/img5.gif' /></li>
<li><img src='img/img6.gif' /></li>
<li><img src='img/img7.gif' /></li>
<li><img src='img/img8.gif' /></li>
<li><img src='img/img9.gif' /></li>
<li><img src='img/img10.gif' /></li>
<li><img src='img/img11.gif' /></li>
<li><img src='img/img12.gif' /></li>
</ul>";
$objResponse->assign("div1","innerHTML",$text1);
$text2="<a href='javascript:void();'
onclick='xajax_Plugin(3);'>
</a>";
$objResponse->assign("div0","innerHTML",$text2);
break;
case 3:
$script="jQuery('#mycarousel').jcarousel();";
$objResponse->script($script);
$text2="";
$objResponse->assign("div0","innerHTML",$text2);
break;
default: break;
}
return $objResponse;
}
?>

2.4.3.2. jQuery UI,


Tabs Accordion
Query UI JavaScript- jQuery, -
- Web-.
Accordion Tabs. . 2.23 Accordion.
/ , .
, -
.
2. AJAX 105

. 2.23. jQueryUI, Accordion

. 2.24. jQueryUI, Tabs

. 2.24 Tabs,
.
Web-.
Tabs Accordion.
.
Accordion .
. . -
Tabs
.
http://bazakatalogov.ru. -
book_primers/2-6. -
primer_2_6_1.
106 I. Web-

primer_2_6_1:
id ;
id_parent ID ;
name ;
sort ;
prgzag , ';';
prgprg , ';'.
primer_2_6_1 2.23.

2.23

CREATE TABLE 'primer_2_6_1' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'id_parent' int( 11 ) default NULL ,
'name' varchar( 50 ) default NULL ,
'sort' int( 5 ) NOT NULL ,
'prgzag' varchar( 120 ) default NULL ,
'prgprg' varchar( 120 ) default NULL ,
UNIQUE KEY 'id' ( 'id' ) ,
KEY 'sort' ( 'sort' )
) ENGINE = MYISAM AUTO_INCREMENT = 135DEFAULT CHARSET = cp1251

- book_primers/primer2-6.sql.
primer_2_6_1 -
.
index.php Ac-
cordion, Tabs (
Accordion Tabs). in-
dex.php 2.24. jQuery, -
jQuery UI, xajax .
sunny jQuery UI. ,
( -). onload
Accordion.

2.24

<?php
// xajax
require_once ("xajax_core/xajax.inc.php");
require_once ("create_accordion.php");
require_once ("new_tabs.php");
$xajax = new xajax();
//
$xajax->register(XAJAX_FUNCTION,"Create_Accordion");
2. AJAX 107

$xajax->register(XAJAX_FUNCTION,"New_Tabs");

$xajax->processRequest();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<!--<link type="text/css" href="css/ui-lightness/jquery-ui-1.7.3.custom.css"
rel="stylesheet" />
<link type="text/css" href="css/cupertino/jquery-ui-1.7.3.custom.css"
rel="stylesheet" />
<link type="text/css" href="css/pepper-grinder/jquery-ui-1.7.3.custom.css"
rel="stylesheet" />
<link type="text/css" href="css/dark-hive/jquery-ui-1.7.3.custom.css"
rel="stylesheet" />
<link type="text/css" href="css/swanky-purse/jquery-ui-1.7.3.custom.css"
rel="stylesheet" />
-->
<link type="text/css" href="css/sunny/jquery-ui-1.7.3.custom.css"
rel="stylesheet" />
<title> 1 ( 2) </title>

<script type="text/javascript" src="js/jquery-1.4.2.js"></script>


<script src="js/jquery-ui-1.7.3.custom.min.js"
type="text/javascript"></script>

<?php $xajax->printJavascript(''); ?>

</head>

<body onload='xajax_Create_Accordion();'>
<!-- -->
<div id=header1><b> ( 2 6)<br>
jQuery UI Tabs Accordion </b></div>
<br>
<!-- -->
<table width=100%>
<tr>
<td width=20%>
<!-- Accordion-->
<div id='accordion1'></div>
</td>
<td width=5%></td>
<td width=75% style='vertical-align:top'>
108 I. Web-

<!-- -->
<div id='zag1'></div>
<!-- Tabs-->
<div id='alltabs1'></div>
</td>
</tr>
</table>
</body>
</html>

xajax- Create_Accordion,
create_accordion.php. Accordion
, 2.25.

2.25

<h4><a href='#'> 1</a></h4>


<div>
<div style='cursor:pointer' onclick='xajax_New_Tabs(4);'> 1</div>
<div style='cursor:pointer' onclick='xajax_New_Tabs(5);'> 2</div>
<div style='cursor:pointer' onclick='xajax_New_Tabs(6);'> 3</div>
</div>
<h4><a href='#'> 2</a></h4>
<div>
<div style='cursor:pointer' onclick='xajax_New_Tabs(7);'> 4</div>
<div style='cursor:pointer' onclick='xajax_New_Tabs(8);'> 5</div>
</div>
<h4><a href='#'> 3</a></h4>
<div>
<div style='cursor:pointer' onclick='xajax_New_Tabs(9);'> 6</div>
<div style='cursor:pointer' onclick='xajax_New_Tabs(10);'> 7</div>
</div>

div id=accordion1. js- -


accordion:
$('#accordion1').accordion({autoHeight:false});
Tabs 1. -
, 2.26.

2.26

<ul>
<li id='li1'><a href='#tabs1'>1-1</a></li>";
<li id='li2'><a href='#tabs2'>1-2</a></li>";
<li id='li3'><a href='#tabs3'>1-3</a></li>";
2. AJAX 109

<li id='li4'><a href='#tabs4'>1-4</a></li>";


<li id='li5'><a href='#tabs5'>1-5</a></li>";
</ul>
<div id='tabs1'> prg1-1</div>
<div id='tabs2'> prg1-2</div>
<div id='tabs3'> prg1-3</div>
<div id='tabs4'> prg1-4</div>
<div id='tabs5'> prg1-5</div>

div id=alltabs1. js- -


Tabs:
$('#alltabs1').tabs({fxFade: true,fxSpeed:'slow'})
create_accordion.php 2.27.

2.27

<?php
function Create_Accordion()
{
$objResponse = new xajaxResponse();
//
require_once("mybaza.php");
// accordion
$content1="";
$query11="SELECT * FROM ".TABLE1." WHERE
id_parent='0' ORDER BY sort ASC ";
$rez11=mysql_query($query11);
while($row11=mysql_fetch_assoc($rez11))
{
$content1.="<h4><a href='#'>".$row11[name]."</a></h4>";
$query12="SELECT * FROM ".TABLE1." WHERE id_parent='".$row11[id]."'
ORDER BY sort ASC ";
$rez12=mysql_query($query12);
$content1.="<div>";
while($row12=mysql_fetch_assoc($rez12))
{
$content1.="<div style='cursor:pointer'
onclick='xajax_New_Tabs(".$row12[id].");'>".$row12[name]."</div>";
}
$content1.="</div>";
}
// accordion
$objResponse->assign("accordion1","innerHTML",$content1);
// accordion
110 I. Web-

$objResponse->script("$('#accordion1').accordion({autoHeight:
false})");
// Tabs Accordion
//
$query13="SELECT * FROM ".TABLE1." WHERE id_parent='1'
ORDER BY sort ASC LIMIT 1, 2 ";
$rez13=mysql_query($query13);
$row13=mysql_fetch_assoc($rez13);
//
$objResponse->assign("zag1","innerHTML","<h3>".$row13[name]."</h3>");
$content21="<ul>";$content22="";
$arrzag=explode(";",$row13[prgzag]);
$arrprg=explode(";",$row13[prgprg]);
for($i=1;$i<count($arrzag);$i++)
for($i=1;$i<count($arrzag);$i++)
{
if($arrzag[$i-1]<>"")
{
$content21.="<li id='li".$i."'>
<a href='#tabs".$i."'>".$arrzag[$i-1]."</a></li>";
$content22.="<div id='tabs".$i."'>".do_prg($arrprg[$i-1])."</div>";
}
else
{
$content21.="<li id='li".$i."'></li>";
$content22.="<div id='tabs".$i."'></div>";
}
}
$content21.="</ul>";
// tabs
$objResponse->assign("alltabs1","innerHTML",$content21.$content22);
// Tabs
$objResponse->script("$('#alltabs1').tabs({fxFade: true,fxSpeed:
'slow'})");
return $objResponse;
}
function do_prg($arg)
{
return " ".$arg;
}
?>

. 2.25.
2. AJAX 111

. 2.25. 2-6

Accordion xajax-
New_Tabs, new_tabs.php ( 2.28).
id=alltabs1, Tabs, -
js-:
$('#alltabs1').tabs('destroy')
Tabs
Tabs id=alltabs1. -
. 2.26.

2.28

<?php
function New_Tabs($Id)
{
$objResponse = new xajaxResponse();
// alltabs1
$objResponse->assign("alltabs1","innerHTML","");
// destroy tabs
$objResponse->script("$('#alltabs1').tabs('destroy')");
//
require_once("mybaza.php");
//
$query13="SELECT * FROM ".TABLE1." WHERE id='".$Id."' ";
$rez13=mysql_query($query13);
$row13=mysql_fetch_assoc($rez13);
//
$objResponse->assign("zag1","innerHTML","<h3>".$row13[name]."</h3>");
//
$arrzag=explode(";",$row13[prgzag]);
$arrprg=explode(";",$row13[prgprg]);
$content21="<ul>";
112 I. Web-

for($i=1;$i<count($arrzag);$i++)
{
if($arrzag[$i-1]<>"")
{
$content21.="<li id='li".$i."'><a href='#tabs".$i."'>
".$arrzag[$i-1]."</a></li>";
$content22.="<div id='tabs".$i."'>".do_prg($arrprg[$i-1])."</div>";
}
else
{
$content21.="<li id='li".$i."'></li>";
$content22.="<div id='tabs".$i."'></div>";
}
}
$content21.="</ul>";
// alltabs1
$objResponse->assign("alltabs1","innerHTML",$content21.$content22);
// tabs
$objResponse->script("$('#alltabs1').tabs({fxFade: true,fxSpeed:
'slow'})");
return $objResponse;
}
?>

. 2.26.

Tabs .
-
, do_prg,
create_accordion.php.
(-
2.29).
2. AJAX 113

2.29

function do_prg($arg)
{
switch($arg)
{
case prg1-1: $result=f11();
break;

case prg5-5: $result=f55();


break;

}
$result;
}

2.4.3.3.
-
( ) gif- -
, .
: imageFlow ( ), fancybox (
). jQuery.
xajax " "
"". - book_primers/2-7.
. 2.27.

. 2.27.
114 I. Web-

:
primer_2_7_kategory ;
primer_2_7_tovars ;
primer_2_7_images ;
primer_2_7_content " ", "";
primer_2_7_rate ;
primer_2_7_zakaz .
2.30
( - book_primers/primer2-7.sql).

2.30

CREATE TABLE 'book_xajax1'.'primer_2_7_kategory' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'name_rus' varchar( 20 ) default NULL ,
'name_eng' varchar( 20 ) default NULL ,
'sort' int( 5 ) NOT NULL ,
'visible' set( 'yes', 'no' ) NOT NULL default 'yes',
UNIQUE KEY 'id' ( 'id' ) ,
KEY 'sort' ( 'sort' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251
CREATE TABLE 'book_xajax1'.'primer_2_7_tovars' (
'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'name_rus' varchar( 20 ) default NULL ,
'name_eng' varchar( 20 ) default NULL ,
'id_kategory' int( 9 ) NOT NULL ,
'sort' int( 5 ) NOT NULL ,
'info_rus' text,
'info_eng' text,
'pay_rus' float( 10, 2 ) default NULL ,
'pay_eng' float( 5, 2 ) default NULL ,
'visible' set( 'yes', 'no' ) NOT NULL default 'yes',
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251
CREATE TABLE 'book_xajax1'.'primer_2_7_images' (
'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'id_tovar' int( 9 ) NOT NULL ,
'name' varchar( 40 ) default NULL ,
'sort' int( 5 ) NOT NULL ,
'info_rus' varchar( 20 ) NOT NULL ,
'info_eng' varchar( 20 ) NOT NULL ,
'visible' set( 'yes', 'no' ) NOT NULL default 'yes',
UNIQUE KEY 'id' ( 'id' )
2. AJAX 115

) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251


CREATE TABLE 'book_xajax1'.'primer_2_7_content' (
'id' int( 2 ) NOT NULL AUTO_INCREMENT ,
'zag_rus' varchar( 20 ) NOT NULL ,
'zag_eng' varchar( 20 ) NOT NULL ,
'info_rus' text NOT NULL ,
'info_eng' text NOT NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251
CREATE TABLE 'book_xajax1'.'primer_2_7_rate' (
'id' int( 5 ) NOT NULL AUTO_INCREMENT ,
'data' date NOT NULL ,
'usd' float( 8, 4 ) default NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251
CREATE TABLE 'book_xajax1'.'primer_2_7_zakaz' (
'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'data_zakaz' datetime NOT NULL ,
'data_oplata' date NOT NULL ,
'data_dostavka' date NOT NULL ,
'id_tovar' int( 9 ) NOT NULL ,
'name' varchar( 20 ) NOT NULL ,
'phone' varchar( 15 ) NOT NULL ,
'email' varchar( 30 ) NOT NULL ,
'address' varchar( 100 ) NOT NULL ,
'oplata' set( 'yes', 'no' ) NOT NULL default 'no',
'dostavka' set( 'yes', 'no' ) NOT NULL default 'no',
'visible' set( 'yes', 'no' ) NOT NULL default 'yes',
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM DEFAULT CHARSET = cp1251;

, primer_2_7_kategory,
primer_2_7_tovars primer_2_7_content .
primer_2_7_rate .
primer_2_7_images .
primer_2_7_zakaz . -
my.php.
index.php , HTTP-
, -
. " " "" xajax-
, . index.php
2.31.
116 I. Web-

2.31

<?php
require_once('index.common.php');
require_once("mybaza.php");
require_once("my.php");
//
$query0="SELECT usd FROM ".BAZA_RATE." ORDER BY id DESC LIMIT 0, 1 ";
$_SESSION[usd]=mysql_result(mysql_query($query0),0);
if(!isset($_GET[prg]))
$_SESSION[language]=LANGUAGE;
else
$_SESSION[language]=$_GET[language];
//
if(!isset($_GET[tovar]))
$_SESSION[tovar]=TOVAR_ID;
else
$_SESSION[tovar]=$_GET[tovar];
// tovar,about, contacts
if(!isset($_GET[prg]))
$_SESSION[prg]='tovar';
else
$_SESSION[prg]=$_GET[prg];
// tovar
if($_SESSION[prg]=='tovar')
{
//
$query11="SELECT * FROM ".BAZA_TOVAR." WHERE id=".$_SESSION[tovar]." ";
$rez11=mysql_query($query11);
$row11=mysql_fetch_assoc($rez11);
//
$query12="SELECT * FROM ".BAZA_KATEGORY." WHERE
id=".$row11[id_kategory]." ";
$rez12=mysql_query($query12);
$row12=mysql_fetch_assoc($rez12);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru">
<head>
<meta http-equiv="Content-Type" charset=windows-1251" >
<title>Title</title>
<link rel="stylesheet" type="text/css" href="css/reset.css" >
<link rel="stylesheet" type="text/css" href="css/typography.css">
2. AJAX 117

<link rel="stylesheet" type="text/css" href="css/style.css" >


<style type="text/css">
img, div { behavior: url(iepngfix.htc) }
</style>
<link rel="stylesheet" href="js/fancybox/jquery.fancybox-1.3.0.css"
type="text/css" media="screen">
<script type="text/javascript" src="iepngfix_tilebg.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/fancybox/jquery.fancybox-
1.3.0.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.sub + ul').hide();
$('.sub').toggle(
function(){$(this).next('ul').slideDown(500); },
function(){$(this).next('ul').slideUp(500); }
);
<?php
//
if($_SESSION[prg]=='tovar')
echo '$("#ul'.$row12[id].'").slideDown(500),';
?>
$("a#inline").fancybox({
'overlayColor': '#000',
'overlayOpacity': 0.7,
'showCloseButton': false,
'padding': 0,
'margin': 0,
'titleShow': false,
'showNavArrows': false,
'width':651,
'height':402,
'autoDimensions':false
});
});
</script>
<link rel="stylesheet" href="imageflow.packed.css" type="text/css" />
<script type="text/javascript" src="imageflow.js"></script>
<?php $xajax->printJavascript(''); ?>
</head>
<?php
if($_SESSION[prg]=='tovar')
echo "<body>";
// xajax-
elseif($_SESSION[prg]=='contacts')
118 I. Web-

echo "<body onload='xajax_Contacts();'>";


else
echo "<body onload='xajax_About();'>";
?>
<div id="container">
<div id="header">
<div id="sl">
<?php
$query14="SELECT info_".$_SESSION[language]." FROM ".BAZA_CONTENT." WHERE id=3
";
$rez14=mysql_query($query14);
$slogan1="";
$slogan1="<p id='slogan1'>".mysql_result($rez14,0)."</p>";
echo $slogan1;
?>
</div>
<div id="lang">
<?php
$lang="";
if($_SESSION[language]=='rus')
$lang="<span> &nbsp;|&nbsp; <a href='index.php?language=eng&prg=".
$_SESSION[prg]."&tovar=".$_SESSION[tovar]."'>Eng</a></span>";
else
$lang="<span><a href='index.php?language=rus&prg=".
$_SESSION[prg]."&tovar=".$_SESSION[tovar]."'>
</a>|&nbsp; Eng &nbsp;</span>";
echo $lang;
?>
</div>
</div>
<div id="side">
<div id="menu">
<div id="menutopbg">
<div id="menubotbg">
<?php
//
$menu1="";
$menu1.="<ul class='menuul'>";
if($_SESSION[language]=='rus')
$menu1.="<li><a class='mitem' href='#'>GIF </a></li>";
else
$menu1.="<li><a class='mitem' href='#'>GIF gallery</a></li>";
$query21="SELECT * FROM ".BAZA_KATEGORY." WHERE visible='yes'
ORDER BY sort ASC ";
$rez21=mysql_query($query21);
2. AJAX 119

while($row21=mysql_fetch_assoc($rez21))
{
$menu1.="<li><a class='mitem sub' href='#'>".
$row21['name_'.$_SESSION[language]]."</a>";
$menu1.="<ul id='ul".$row21[id]."' class='submenu'>";
$query22="SELECT * FROM ".BAZA_TOVAR." WHERE
id_kategory=".$row21[id]." && visible='yes'
ORDER BY sort ASC ";
$rez22=mysql_query($query22);
while($row22=mysql_fetch_assoc($rez22))
{
$menu1.="<li><a class='smitem' href='index.php?language=".
$_SESSION[language]."&prg=tovar&tovar=".$row22[id]."'";
$menu1.=">".$row22['name_'.$_SESSION[language]]."</a></li>";
}
$menu1.="</ul>";
$menu1.="</li>";
}
$menu1.="</ul>";
echo $menu1;
?>
</div>
</div>
</div>
<div id=menu2>
<?php
//
$menu2="<ul class='menuul'>";
if($_SESSION[language]=='rus')
{
$menu2.="<li class='mitem nobg'><a href='index.php?language=rus&prg=
about&tovar=".$_SESSION[tovar]."' class='nobg'> </a></li>";
$menu2.="<li class='mitem nobg'><a href='index.php?language=rus&prg=
contacts&tovar=".$_SESSION[tovar]."' class='nobg'></a></li>";
}
else
{
$menu2.="<li class='mitem nobg'><a href='index.php?language=eng&prg=
about&tovar=".$_SESSION[tovar]."' class='nobg'>About</a></li>";
$menu2.="<li class='mitem nobg'><a href='index.php?language=eng&prg=
contacts&tovar=".$_SESSION[tovar]."' class='nobg'>Contacts</a></li>";
}
$menu2.="</ul>";
echo $menu2;
120 I. Web-

?>
</div>
</div>
<div id="main">
<div id='headtovar'>
<?php
//
if($_SESSION[prg]=='tovar')
{
$zag="";
$zag.="<h2 class='heading'>".$row12['name_'.$_SESSION[language]]." / ";
$zag.=$row11['name_'.$_SESSION[language]]."</h2>";
}
elseif($_SESSION[prg]=='contacts')
{
if($_SESSION[language]=='rus')
$zag="<h2 class='heading'> </h2>";
else
$zag="<h2 class='heading'> Contacts </h2>";
}
else
{
if($_SESSION[language]=='rus')
$zag="<h2 class='heading'> </h2>";
else
$zag="<h2 class='heading'> About </h2>";
}
echo $zag;
?>
</div>
<div id="myImageFlow" class="imageflow">
<?php
//
$images="";
$query13="SELECT * FROM ".BAZA_IMAGES." WHERE
id_tovar=".$_SESSION[tovar]." ORDER BY sort ASC";
$rez13=mysql_query($query13);
while($row13=mysql_fetch_assoc($rez13))
{
$images.="<img src='img/".$row13[name]."' ";
$images.="longdesc='img/".$row13[name]."' ";
$images.="alt='".$row13[name]."' />";
}
if($_SESSION[prg]=='tovar')
echo $images;
2. AJAX 121

?>
</div>
<div id="opisanie" class="opisanie">
<?php
if($_SESSION[prg]=='tovar')
{
$opisanie="";
$opisanie.=$row11['info_'.$_SESSION[language]];
echo $opisanie;
}
?>
</div>
<br>
<div id="allprice">
<?php
if($_SESSION[language]=='rus')
{
$price="<div id='price'>";
$price.="<span id='spanprice'>: <span>".$row11[pay_rus]."
.</span></span>";
$price.="<a id='inline' href='#data'></a>";
$price.="</div>";
}
else
{
$price="<div id='price'>";
$price.="<span>Pay: <span>".sprintf('%5.0f',
($row11[pay_rus]/$_SESSION[usd]))." $</span></span>";
$price.="<a id='inline' href='#data'></a>";
$price.="</div>";
}
if($_SESSION[prg]=='tovar')
echo $price;
else
echo "<table></table>";
?>
</div>
<div id="footer"><span class="left"></span><span class="right"></span></div>
</div>
<div class="clear"></div>
</div>
<div style="display: none;;">
<div id="data">
<?php
$tovar=$row12['name_'.$_SESSION[language]]." /
".$row11['name_'.$_SESSION[language]];
122 I. Web-

if($_SESSION[language]=='rus')
{
$name=" ";
$phone=" <br/> ";
$email="E-mail";
$adress=" ";
}
else
{
$name="Your name";
$phone="Contact <br/> phone";
$email="E-mail";
$adress="Address";
}

$data="<form id='Form_Zakaz' action='javascript:void(null);' onsubmit='


xajax_Create_Zakaz(xajax.getFormValues(\"Form_Zakaz\"));' >
<table id='buy'>
<tr><td></td><td><h3>".$tovar."</h3></td></tr>
<tr><td class='right'>".$name."</td><td><input name='name' type='text'>
<input name='tovar' value='".$_SESSION[tovar]."' type='hidden'></td></tr>
<tr><td class='right'>".$phone."</td><td>
+<input name='phone1' id='phone1' type='text' size=2 maxlength=2
value=''>
(<input name='phone2' id='phone2' type='text' value='' size=5 maxlength=5>)
<input name='phone3' id='phone3' type='text' value='' size=7 max-
length=7></td></tr>
<tr><td class='right'>".$email."</td><td><input name='email' id='email'
type='text' value=''></td></tr>
<tr><td class='right'>".$adress."</td><td><textarea name='address' cols='40'
rows='3'></textarea></tr>
<tr><td></td><td><input name='submit' type='image' src='img/submit.png'
id='submit'></td></tr>
</table>
</form>";
echo $data;
?>
</div>
</div>
<div id="big_img" style='position:absolute;z-index:29999900;
margin: 20px;top:5%;left:5%;opacity:1.0;
width:90%;height:auto;display:none;
background-color: rgb(0,0,0)' onclick='this.style.display="none";'
onmouseout='this.style.display="none";'>
</div>
</body>
</html>
2. AJAX 123

. 2.28.
create_zakaz.php 2.33. imageFlow
.
, .
"". -
div c id=big_img ,
. imageflow.js
click imageflow ( 2.32).

2.32

/*onClick: function() { document.location = this.url; }, */


/* Onclick behaviour */
onClick: function()
{document.getElementById('big_img').style.display='block';
document.getElementById('big_img').innerHTML=
'<img src="'+this.url+'" width=100%> '},

. 2.29.

:
onclick='this.style.display="none";'
onmouseout='this.style.display="none";'

. 2.28.
124 I. Web-

(. 2.30)
fancybox.
xajax- Create_Zakaz,
create_zakaz.php ( 2.33). -

e-mail .

. 2.29.

. 2.30.
2. AJAX 125

2.33

<?php
function Create_Zakaz($Id)
{
$objResponse = new xajaxResponse();
//
require_once("mybaza.php");
//
require_once("my.php");
//
$tovar=$Id[tovar];
$name=utftowin($Id[name]);
$phone1=$Id[phone1];
$phone2=$Id[phone2];
$phone3=$Id[phone3];
$email=$Id[email];
$address=utftowin($Id[address]);
// ******* ****
$error="";
// name
if(!ereg("^([a-z,A-Z,-,-,0-9,\ ]{6,50})$",$name))
{
if($_SESSION[language]=='rus')
$error.=" ";
else
$error.=" name ";
}
// phone
if(!ereg("^([0-9,\+\(\)]{1,2})$",$phone1))
{
if($_SESSION[language]=='rus')
$error.=" ( )";
else
$error.=" phone ( )";
}
if(!ereg("^([0-9,\+\(\)]{3,5})$",$phone2))
{
if($_SESSION[language]=='rus')
$error.=" ( )";
else
$error.=" phone ( town)";
}
if(!ereg("^([0-9,\+\(\)]{5,7})$",$phone3))
126 I. Web-

{
if($_SESSION[language]=='rus')
$error.=" ()";
else
$error.=" phone (number)";
}
// email
if(!ereg("^([a-z,0-9,-_\.]{2,20})([\@]{1})([a-z,0-9,-_]{2,20})
([\.]{1})([a-z,]{1,3})$",$email))
{
if($_SESSION[language]=='rus')
$error.=" e-mail ";
else
$error.=" e-mail ";
}
if(strlen(trim($address))==0)
{
if($_SESSION[language]=='rus')
$error.=" ";
else
$error.=" address ";
}
//
if($error<>"")
{
$objResponse->alert($error);
return $objResponse;
}
// **** e-mail ****
//
$phone="+".$phone1."(".$phone2.")".$phone3;
$data_zakaz=date('Y-m-d H:i:s');
$query1="INSERT INTO ".BAZA_ZAKAZ." SET data_zakaz='".$data_zakaz."',
id_tovar='".$tovar."',name='".$name."',
phone='".$phone."',email='".$email."',
address='".$address."' ";
$rez1=mysql_query($query1);
$num=mysql_insert_id();
//
$content="";
$content.="<table id='buy'><td><h3>";
if($_SESSION[language]=='rus')
$content.="<center><br><br><br> <center>
<br> <br> ".$num."</center>";
else
2. AJAX 127

$content.="<center><br><br><br> Your zakaz <br> <br>Number


zakaz ".$num." </center>";
$content.="</h3></td></tr></table>";
//
$objResponse->assign("data","innerHTML",$content);
//
$query2="SELECT kategory.name_rus,tovar.name_rus FROM
kategory,tovar WHERE tovar.id=".$tovar." &&
kategory.id=tovar.id_kategory ";
$rez2=mysql_query($query2);
$row2=mysql_fetch_row($rez2);
$to=EMAILADMIN;
$subject=' '.SITE;
$body='<b> '.SITE.'</b><br>';
$body.='<b> </b><br>';
$body.='<b>'.$row2[0].' \ '.$row2[1].'</b><br><br>';
$body.='<b> : </b><br>';
$body.='<b> </b>'.$name.'<br>';
$body.='<b> </b>'.$phone.'<br>';
$body.='<b>E-mail </b>'.$email.'<br>';
$body.='<b> </b>'.$address.'<br>';
$body.='<b> </b>'.date('d-m-Y H:i:s').'<br>';
$body.='<b> </b>'.$num.'<br>';
$body.='<br>';
$headers="Content-type: text/html; charset=windows-1251;";
mail($to,$subject,$body,$headers);
return $objResponse;
}
?>

2.5. Xajax Smarty

2.5.1. Smarty
Smarty PHP,
, . , -
(
). , , .
, ,
, . Smarty-,
HTML
, (
HTML, , , . .). -
( ).
128 I. Web-

. -
. , -
,
. ,
,
.
, , ,
. , -
, ,
,
. . . , Smarty
. Smarty " "
, -
. ,
,
.
Smarty:
.
, PHP "" .
, .
, .
,
.
, {}, {{}},
<!--{}--> . .
if/elseif/else/endif PHP,
{if ...} ( ).
, . .
PHP- ,
( ), . .
.
.
.
.
.

2.5.2. Smarty
Smarty ,
http://www.smarty.net/download.php. (. 2.31)
, (Latest Stable Release 2.6.26)
2. AJAX 129

zip (. 2.31). . -
.
Smarty ( 2.34).

. 2.31. Smarty

2.34

// index.php
<?php
//
require_once("Smarty/libs/Smarty.class.php");
//
$smarty = new Smarty();
//
$smarty->template_dir = 'my_templates';
$smarty->compile_dir = 'my_templates_c';

$value1="1";
$value2=" ";
// Smarty
$smarty->assign("zag",$value1);
$smarty->assign("txt",$value2);
130 I. Web-

//
$smarty->display("index.tpl.html");
?>
// index.tpl.html

<b>{$zag}</b>
<br>
{$txt}

index.php :
1

2.5.3. Smarty
Smarty ,
. . ,
Smarty? (-
, . .) HTML-. ()
Smarty -.
{ }, . , -
, Smarty , .
index.tpl.html ( 2.34) {$zag} {$txt} ,
, .
Smarty :
{* .
*}
Smarty- , -
.
:
{_ 1="1"
2="2"}
:
, PHP- ,
:
{$first_name}
, PHP- ,
{$_._}:
{$person.last_name}
-
{$_[_]}:
$person[2]}
2. AJAX 131

, PHP-,
{$_->_}:
{$person->email}
, ( , -
), #.
$smarty.config:
{#bodyBgColor#} {$smarty.config.bodyBgColor}
{$smarty}, -
(HTTP-, . .).
Smarty ,
, , -
. ,
, , -
, .
, {$title} , -
upper, . . : {$title|upper}.
, -
. , {$title|upper|truncate} -
80 .
.
Smarty. ,
, , ,
, .

2.5.4. Smarty
Smarty .
,
xajax Smarty.
2.5.4.1. assign
:
void assign ( );
void assign ( ,
);
( 2.35).

2.35

<?php
//
// Name
$smarty->assign("Name","");
// , Name
//
?>
132 I. Web-

2.5.4.2. display
:
void display( );
.

<?php
$smarty->display("template1.tpl");
?>

2.5.4.3. fetch
:
string fetch();

, .

<?php
$x=$smarty->fetch("template1.tpl");
?>

2.5.5. xajax Smarty


xajax Smarty.
Smarty:
;
.
, . 2.3.2.
10 .
, (
). -
book_primers/2-8. index.php ( 2.36)
. 2.32. xajax- -
:
{$xajax_javascript}
index.php:
$smarty->assign("xajax_javascript", $xajax->getJavascript("."));
my_templates/index.tpl.html ( 2.37).
2. AJAX 133

. 2.32. 2-8

2.36

<?php
// Smarty
require_once("Smarty/libs/Smarty.class.php");
//
$smarty = new Smarty();
//
$smarty->template_dir = 'my_templates';
$smarty->compile_dir = 'my_templates_c';
// xajax
require_once ("xajax_core/xajax.inc.php");
//
require_once ("result_select.php");
$xajax = new xajax();
//
$xajax->register(XAJAX_FUNCTION,"Result_Select");
//
$xajax->processRequest();
//
require_once("mybaza.php");
//
$query1="SELECT id,name,socr FROM ".TABLE1." WHERE id_rayon=0 &&
id_town=0 && id_punkt=0 ORDER BY id ASC";
$rez1=mysql_query($query1);
$i=0;
while($row1=mysql_fetch_assoc($rez1))
{
$i++;
$info[$i][id]=$row1[id];
$info[$i][name]=$row1[name];
$info[$i][socr]=$row1[socr];
}
134 I. Web-

// xajax-
$smarty->assign("xajax_javascript", $xajax->getJavascript("."));
//
$smarty->assign("info", $info);
//
$smarty->display("index.tpl.html");
?>

2.37

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title> 8 ( 2) </title>
{$xajax_javascript}
</head>
<body>
<!-- -->
<div id=header1><b> ( 2 8)<br>
c Smarty </b></div>
<br>
<!-- -->
<form id='FormSelectRegion' method='post' action='javascript:void(null);'
onsubmit='
xajax.$("ButtonFormSelectRegion").disabled=true;
xajax.$("ButtonFormSelectRegion").value="...";
xajax_Result_Select(xajax.getFormValues("FormSelectRegion"));'
enctype="multipart/form-data";>
<input type='hidden' id='number' name='number' value='0'><br>
<input type='hidden' id='vibor' name='vibor' value='0'><br>
<b> </b><br>
<! -- >
<div>
<select id=template name=template>
<option value=1> 1
<option value=2 selected> 2
<option value=3> 3
</select>
</div>
<b> </b><br>
<div id='divselectregion1'>
<select name=selectregion1 id='selectregion1' >
{foreach from=$info item=item}
2. AJAX 135

<option value={$item.id} >{$item.name} {$item.socr}


{/foreach}
</select></div>
<input type='submit' id='ButtonFormSelectRegion' value='' >
</form>
<div id='div_result'></div>
</body>
</html>

, .
xajax- Result_Select, -
. - $info. -
Smarty:
$smarty->assign("info", $info);
Smarty ,
. ,
:
$content=$smarty->fetch('template2.html');
xajax-:
$objResponse->assign("div_result","innerHTML",$content);
Result_Select result_select.php ( 2.38).

2.38

<?php
function Result_Select($Id)
{
$objResponse = new xajaxResponse();
// Smarty
//require_once("Smarty/libs/Smarty.class.php");
//
$smarty = new Smarty();
//
$smarty->template_dir = 'my_templates';
$smarty->compile_dir = 'my_templates_c';
//
require_once("mybaza.php");
//
$query1="SELECT id,name,socr FROM ".TABLE1." WHERE id_punkt=0
&& id_region='".substr($Id[selectregion1],1,2)."'
&& id_town=0 && id_rayon>0
ORDER BY id ASC LIMIT 0, 10";
$rez1=mysql_query($query1);
$i=0;
136 I. Web-

while($row1=mysql_fetch_assoc($rez1))
{$i++;
$info[$i][id]=$row1[id];
$info[$i][name]=$row1[name];
}
// Smarty
$smarty->assign("info", $info);
//
//
if($Id[template]==1)
$content=$smarty->fetch('template1.tpl.html');
elseif($Id[template]==2)
$content=$smarty->fetch('template2.html');
else
$content=$smarty->fetch('template3.html');
// xajax
$objResponse->assign("div_result","innerHTML",$content);
$objResponse->assign("ButtonFormSelectRegion","value","");
$objResponse->assign("ButtonFormSelectRegion","disabled",false);
return $objResponse;
}
?>

. 2.33. template1.tpl.html
2. AJAX 137

. 2.34. template2.html

. 2.35. template3.html

. 2.332.35 -
. (template1.tpl.html, template2.html, template3.html)
138 I. Web-

my_templates. -
:
$smarty->template_dir = 'my_templates';
$smarty->compile_dir = 'my_templates_c';
2.39.

2.39

// my_templates/template1.tpl.html
<table>
{foreach from=$info item=item}
<tr style="border-style:;border-width:4">
<td style="color:red;font-weight: bold;">{$item.id}</td>
<td> >>> {$item.name}</td>
</tr>
{/foreach}
</table>
// my_templates/template2.html
<table>
{foreach from=$info item=item}
<tr>
<td style="font-style:italic">{$item.id}</td>
<td style="font-style:italic;font-weight: bold;font-size: 20px "> -->
{$item.name}</td>
</tr>
{/foreach}
</table>
// my_templates/template3.html
<table>
{foreach from=$info item=item}
<tr>
<td style="background-color:yellow"><b> {$item.id}</b></td>
</tr>
<tr>
<td>{$item.name}</td>
</tr>
{/foreach}
</table>
II
-
3

3.1.
(-
- ),
. . -
.

3.1.1.
(- )
, , -
. :
:
"" .
,
, , , .
,
. -
, , , "" -
. cookies
. "" "-
" ,
, . -

;
. , -
,
SMS , -
a1agregator.ru.
:
;
;
142 II. -

;
;
.
:
-
(drag&drop);
: , , -
1000 ;
"": , ,
, ;
.
:
;
"" (Webmoney ONPAY);
;
;
.
:
;
.
:
;
;
;
-
.
:
e-mail ;
ICQ .
:
, , ;
, , ;
, , , ;
.
4.
3. 143

3.1.2.
.
3.1.

3.1

/www
/arhivtovar #
/cron # cron
/css #
/epoch_v106_ru #
/img #
/imgtovar #
/js # js
/prgcontacts #
/prginfooplata #
/prgkategory #
/prgkorzina #
/prgmessage #

/prgmessage_admin #
()
/prgmessageheader4 #
/prgoplata #
/prgpopup #
/prgrate #
/prgreg #
/prgstat #
/prgtovars #
/prgtovars_admin # ()
/prgusers_admin # ()
/prgvhod #
/prgzakaz #
/prgzakaz_admin # ()
/tmp1 #
/tmparhiv #
/tmpimg #
/xajax_core # xajax

3.1.3.

, . -
index.php ( !) .
144 II. -

(div) (. 3.1). -
, AJAX- onclick,
:
<a href="javascript:void()" onclick="xajax_Zakaz(1);"></a>
-
.
( 3.2).

3.2

<?php
$objResponse = new xajaxResponse();
$content=" ";
$objResponse->assign("center2","innerHTML",$ content);
return $objResponse;
?>

,
innerHTML (HTML ) <table></table> ( 3.3).

3.3

<?php
$objResponse = new xajaxResponse();
$content="<table></table>t";
$objResponse->assign("center2","innerHTML",$ content);
return $objResponse;
?>

JavaScript- ,
, 3.4.

3.4

<?php
$objResponse = new xajaxResponse();
// jQuery- id=table1
// rgb(230,230,230)
$script="$('tr:nth-child(odd)','#table1').css('background-
color','rgb(230,230,230)');";
$objResponse->script($script);
return $objResponse;
?>

, "-
" . ,
3. 145

drag&drop, ,
SMS . div
position:absolute,z-index:900 -
( display:none).

. 3.1. index.php

3.1.4.
-
:
users ;
mainmenu
;
kategory ;
tovars ;
zakaz (, , , . .);
zakaz_table ;
link_downloads ;
messages "";
message_header4 ;
146 II. -

oplata_reg SMS ;
oplata "" ;
link_partners ;
rate ( www.cbr.ru).
.
visible yes no -
/ (/) .
, , mainmenu, ,
, users ().
users:
id ;
data ;
login ;
password ;
type :
1 ;
2 ;
9 ;
memory ;
visible :
yes ;
no ;
block ;
discount ( 0);
email e-mail ;
ip IP , ;
(89.67.234.45;123.34.56.89);
vizits .
3.5 users.

3.5

CREATE TABLE 'magazin'.'users' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'data' datetime NOT NULL ,
'login' varchar( 32 ) NOT NULL ,
'password' varchar( 12 ) default NULL ,
'type' set( '1', '2', '8', '9' ) NOT NULL ,
'memory' int( 1 ) NOT NULL default '0',
'visible' set( 'yes', 'no', 'block' ) NOT NULL ,
3. 147

'discount' float( 2, 0 ) NOT NULL ,


'email' varchar( 30 ) NOT NULL ,
'ip' tinytext,
'vizits' int( 5 ) default '0',
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

, login -
32 , 12 . ,
"" "",
login 32-
.
, -
. -
.
mainmenu.
mainmenu -
:
id ;
status ;
name ("", "");
sort ;
prgprg ( ;);
prgdiv ,
prgprg;
visible :
yes ;
no ;
img .
3.6 mainmenu.

3.6

CREATE TABLE 'magazin'.'mainmenu' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'status' set( '1', '2', '8', '9' ) default NULL ,
'name' varchar( 50 ) default NULL ,
'sort' int( 5 ) NOT NULL ,
'prgdiv' mediumtext,
'prgprg' mediumtext,
'visible' set( 'yes', 'no' ) NOT NULL default 'yes',
'img' varchar( 30 ) default NULL ,
148 II. -

UNIQUE KEY 'id' ( 'id' ) ,


KEY 'sort' ( 'sort' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

xajax- ,
id mainmenu. -
, prgprg,
prgdiv.
kategory -
:
id ;
id_parent ID ;
name ;
nn ;
visible :
yes ;
no .
3.7 kategory.

3.7

CREATE TABLE 'magazin'.'kategory' (


'id' int( 5 ) NOT NULL AUTO_INCREMENT ,
'id_parent' int( 5 ) NOT NULL default '0',
'name' varchar( 30 ) NOT NULL default '',
'nn' int( 5 ) NOT NULL default '0',
'visible' set( 'yes', 'no' ) NOT NULL default 'yes',
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

id_parent=0 , nn
. ,
, .
tovars :
id ;
id_kategory ID ;
arhiv ;
img (""
);
name ;
pay_rub , .;
new_pay_rub , . ( );
3. 149

data ;
data_update ;
views ;
pays ;
raiting ;
visible :
"" ;
yes
no "";
artikul ( );
ean13 ean13 ( ).
3.8 tovars.

3.8

CREATE TABLE 'magazin'.'tovars' (


'id' int( 5 ) NOT NULL AUTO_INCREMENT ,
'id_kategory' int( 11 ) default '0',
'arhiv' varchar( 50 ) NOT NULL default '',
'img' varchar( 50 ) NOT NULL default '',
'name' varchar( 50 ) NOT NULL default '',
'info' tinytext NOT NULL ,
'fullinfo' text,
'pay_rub' float( 10, 2 ) default '0.00',
'new_pay_rub' float( 10, 2 ) default '0.00',
'data' datetime default '0000-00-00 00:00:00',
'data_update' datetime default '0000-00-00 00:00:00',
'views' int( 5 ) NOT NULL default '0',
'pays' int( 5 ) default '0',
'raiting' float( 8, 2 ) NOT NULL default '0.00',
'visible' set( 'yes', 'no', 'del' ) default 'no',
'artikul' varchar( 10 ) NOT NULL ,
'ean13' varchar( 13 ) NOT NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

zakaz ():
id ;
data ;
id_user ;
summa_rub ;
summa_rub_oplata ;
150 II. -

pay :
yes ;
no ;
visible :
yes "";
no "" ().
3.9 zakaz.

3.9

CREATE TABLE 'magazin'.'zakaz' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'data' datetime NOT NULL ,
'id_user' int( 9 ) NOT NULL ,
'summa_rub' float( 10, 2 ) NOT NULL ,
'summa_rub_oplata' float( 10, 2 ) NOT NULL ,
'pay' set( 'yes', 'no' ) NOT NULL default 'no',
'visible' set( 'yes', 'no' ) NOT NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

zakaz_table :
id ;
id_zakaz ID ;
id_tovar ID ;
pay_rub ;
kol ;
summa_rub ;
summa_rub_oplata ;
id_link ;
count_download .
, .
3.10 zakaz_table.

3.10

CREATE TABLE 'magazin'.'zakaz_table' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'id_zakaz' int( 9 ) NOT NULL ,
'id_tovar' int( 9 ) NOT NULL ,
'pay_rub' float( 10, 2 ) NOT NULL ,
'kol' int( 9 ) NOT NULL ,
3. 151

'summa_rub' float( 10, 2 ) NOT NULL ,


'summa_rub_oplata' float( 10, 2 ) NOT NULL ,
'id_link' int( 9 ) default NULL ,
'count_download' int( 2 ) default NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

.
( IP ).
data .
link_downloads :
id_link ;
id_user ID ;
id_zakaz ID ;
file ;
status :
yes ;
no ;
data .
3.11 link_downloads.

3.11

CREATE TABLE 'magazin'.'link_downloads' (


'id_link' int( 9 ) NOT NULL AUTO_INCREMENT ,
'id_user' int( 9 ) NOT NULL ,
'id_zakaz' int( 9 ) NOT NULL ,
'file' varchar( 60 ) NOT NULL ,
'status' set( 'yes', 'no' ) NOT NULL ,
'data' date default NULL ,
UNIQUE KEY 'id_link' ( 'id_link' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

messages "":
id ;
data ;
id_to ID ();
id_from ID ();
theme ;
message ;
view_to :
yes ;
no ;
152 II. -

visible_to :
yes "" ;
no "" ;
visible_from :
yes "" ;
no "" .
3.12 messages.

3.12

CREATE TABLE 'magazin'.'messages' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'data' datetime NOT NULL ,
'id_to' int( 9 ) NOT NULL ,
'id_from' int( 9 ) NOT NULL ,
'theme' varchar( 30 ) NOT NULL ,
'message' tinytext NOT NULL ,
'view_to' set( 'yes', 'no' ) NOT NULL default 'no',
'visible_to' set( 'yes', 'no' ) default 'yes',
'visible_from' set( 'yes', 'no' ) default 'yes',
UNIQUE KEY 'id' ( 'id' ) ,
KEY 'data' ( 'data' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

, -
, ,
, , -
, .
visible=no,
. message_header4 :
id ;
data ;
id_user ID , ;
type :
1 ;
2 ( );
3 ;
4 ;
5 ( );
6 ( );
arg_id ID (ID , ID , ID );
3. 153

message ;
visible :
yes ;
no .
3.13 message_header4.

3.13

CREATE TABLE 'magazin'.'message_header4' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'data' datetime NOT NULL ,
'id_user' int( 9 ) NOT NULL ,
'type' set( '1', '2', '3', '4', '5', '6' ) NOT NULL ,
'arg_id' int( 9 ) NOT NULL ,
'message' tinytext NOT NULL ,
'visible' set( 'yes', 'no' ) NOT NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

oplata_reg SMS :
id ;
data SMS-;
phone , SMS-;
kod_reg ( SMS);
activ :
yes ;
no ;
id_user ID , .
3.14 oplata_reg.

3.14

CREATE TABLE 'magazin'.'oplata_reg' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'data' datetime default NULL ,
'phone' varchar( 12 ) NOT NULL ,
'kod_reg' varchar( 12 ) NOT NULL ,
'activ' set( 'yes', 'no' ) NOT NULL ,
'id_user' int( 9 ) NOT NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251
154 II. -

, -
. ,
, , -
SMS-.
oplata , "-
" . oplata:
id ;
data ;
id_zakaz ID , ;
plat_system , ;
kod ;
summa_rub .
3.15 oplata.

3.15

CREATE TABLE 'magazin'.'oplata' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'data' datetime NOT NULL ,
'id_zakaz' int( 9 ) NOT NULL ,
'plat_system' set( 'wm', 'ya', 'sms' ) NOT NULL ,
'kod' varchar( 32 ) default NULL ,
'summa_rub' float( 10, 2 ) NOT NULL ,
UNIQUE KEY 'id' ( 'id' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

,
. link_partners
:
id ;
name ;
link URL ;
sort ;
visible :
yes ;
no .
3.16 link_partners.

3.16

CREATE TABLE 'magazin'.'link_partners' (


'id' int( 5 ) NOT NULL AUTO_INCREMENT ,
'name' varchar( 50 ) NOT NULL ,
3. 155

'link' varchar( 50 ) NOT NULL ,


'sort' int( 3 ) NOT NULL ,
'visible' set( 'yes', 'no' ) NOT NULL default 'yes',
UNIQUE KEY 'id' ( 'id' ) ,
KEY 'sort' ( 'sort' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

www.cbr.ru -
, . -
, cron
. rate :
id ;
data ;
usd ;
eur .
3.17 rate.

3.17

CREATE TABLE 'magazin'.'rate' (


'id' int( 9 ) NOT NULL AUTO_INCREMENT ,
'data' date NOT NULL ,
'usd' float( 10, 3 ) default NULL ,
'eur' float( 10, 3 ) default NULL ,
UNIQUE KEY 'id' ( 'id' ) ,
KEY 'data' ( 'data' )
) ENGINE = MYISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = cp1251

. -
.

3.2. .
3.2.1.
:
;
;
.
.
-
:
, ;
, ;
156 II. -

;
.
,
" " (. . 3.3.2) -
, .

" " cookies
.

:
, , ,
;
, ;
, ;
;
.

3.2.2.
-
. , -
cookies .
cookies ($_COOKIE["session"]).
cookies "" ,
session_id(), " " -
cookies .
cookies . -
" " ,
. " "
.
, -
. -
. xajax_Vhod -
. ,
" ".
users -
( ). ,
" ". (
visible). visible=no ( ) visible=block () -
. visible=yes (-
), SESSION,

. xajax_Vhod
prgvhod/vhod.php ( 3.18).
3. 157

3.18

function Vhod($Id)
{
$objResponse = new xajaxResponse();
// ajax-
$objResponse->assign("flag_ajax","value",'yes');
// mySQL
require_once("mybaza.php");
//
//( -
if(trim($Id['login'])=='' || trim($Id['password'])=='')
{
$objResponse->alert(" !");
$objResponse->assign("ButtonFormVhod","value", " ->");
$objResponse->assign("login","value", "");
$objResponse->assign("password","value", "");
$objResponse->assign("ButtonFormVhod","disabled", false);
return $objResponse;
}
// USERS login-password
$query0="SELECT * FROM users WHERE
password='".utftowin($Id['password'])."'
&& login='".utftowin($Id['login'])."' ";
$rez0=mysql_query($query0);
$row0=mysql_fetch_assoc($rez0);
if(mysql_num_rows($rez0)<1)
{
$objResponse->alert(" !");
$objResponse->assign("ButtonFormVhod","value", " ->");
$objResponse->assign("login","value", "");
$objResponse->assign("password","value", "");
$objResponse->assign("ButtonFormVhod","disabled", false);
return $objResponse;
}
// = no
if($row0[visible]=='no')
{
$objResponse->alert(" !");
$objResponse->assign("ButtonFormVhod","value", " ->");
$objResponse->assign("login","value", "");
$objResponse->assign("password","value", "");
$objResponse->assign("ButtonFormVhod","disabled", false);
return $objResponse;
}
158 II. -

//
if($row0[visible]=='block')
{
$objResponse->alert(" -
!");
$objResponse->assign("ButtonFormVhod","value", " ->");
$objResponse->assign("login","value", "");
$objResponse->assign("password","value", "");
$objResponse->assign("ButtonFormVhod","disabled", false);
return $objResponse;
}
// !
//
// SESSION
//
$_SESSION[type]=$row0[type];
// id
$_SESSION[user]=$row0[id];
// .
// MAINMENU.
//
$query1="SELECT id,name FROM mainmenu WHERE
status='".$_SESSION[type]."'
&& visible='yes' ORDER BY sort ASC ";
$rez1=mysql_query($query1);$i=1;
while($row1=mysql_fetch_assoc($rez1))
{
if($i==1)
{
//
$dataheader3.="&nbsp&nbsp&nbsp&nbsp ".$row1[name];
}
else
//
$dataheader3.="&nbsp&nbsp&nbsp&nbsp <a href='
javascript:void(null)' onclick='
xajax_MainMenu(".$row1[id].");'>".$row1[name]."</a>";
$i++;
}
// header3
$objResponse->assign("header3","innerHTML",$dataheader3);
//
// <a href='javascript:void(null)' onclick='
// xajax_MainMenu(".$row1[id].");'>".$row1[name]."</a>";
//
3. 159

// ,
// .
//
$query20="SELECT id FROM mainmenu WHERE status='".$_SESSION[type]."'
ORDER BY sort ASC LIMIT 1 ";
$rez20=mysql_query($query20);
$query2="SELECT prgdiv,prgprg,id FROM mainmenu
WHERE id=".mysql_result($rez20,0)." ";
$rez2=mysql_query($query2);
$row2=mysql_fetch_row($rez2);
$arraydiv=explode(";",$row2[0]);
$arrayprg=explode(";",$row2[1]);
for($i=0;$i<count($arrayprg);$i++)
{$divcontent="";
switch(trim($arrayprg[$i]))
{
//
case "clear": $divcontent="<table></table>";
break;
case "clearkorzina": $divcontent="<table></table>";
$script= "document.getElementById(
'flag_korzina').value='no';";
break;
// " " ()
case "zagadminkategory": $divcontent=f_zag1("
");
break;
// " " ()
case "adminkategory":
$divcontent="<div class='menu'
id='admin_path_kategory'></div>
<div class='menu' style='margin-left:0'
id='admin_kategory1'></div>";
break;
// ()
case "adminopenkategory":
$divcontent=f_admin_open_kategory(1);
break;
// ()
case "adminpathkategory":
$divcontent="<b>
:</b><br>".f_string_kategory(1);
$divcontent.="<br><a href='javascript:void();' onclick='
xajax_Delete_Admin_Kategory(1);'></a>";
$divcontent.="<br><a href='javascript:void();' onclick='
160 II. -

xajax_Rename_Admin_Kategory(1);'>
</a>";
$divcontent.="<br><a href='javascript:void();' onclick='
xajax_Add_Admin_Kategory(1);'></a>";
break;

case "zaginfooplata": $divcontent=f_zag1("");


break;
case "infooplata": $divcontent1=f_info_oplata();
$divcontent=$divcontent1;
break;
}
//
$objResponse->assign($arraydiv[$i],"innerHTML",$divcontent);
}
//
$dataheader2=" , <b>".$row0[login]."<b>";
$objResponse->assign("header2","innerHTML",$dataheader2);
// -
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}

-
xajax_MainMenu(N),
. -
- ( prgvhod/vhod.php).

3.2.3. SESSION cookies


cookies -
. -
. cookies -
, . cookies
, -, ,
, , -, -
, -, -
.
HTTP " ", . .
. -
,
, , , HTTP,
, . -
3. 161

, ,
Web-.
. ,
, , , , -
, PHP-.
3.2.3.1. session
:
;
;
.
session_start -
PHP-:
session_start();
, , ,
. ,
.

$_SESSION. page1.php,
$_SESSION ( 3.19).

3.19

<?php
//
session_start();
//
$_SESSION[param1] = "123456789";
//
echo "<a href='page2.php'> </a>";
?>

, session_start(), -
$_SESSION. -
3.20 page2.php, ,
page1.php.

3.20

<?php
//
session_start();
// $_SESSION[param1]
echo "$_SESSION[param1]=". $_SESSION[param1];
?>
162 II. -

-
, unset():
unset($_SESSION[param1]);

3.2.3.2. cookie
ookies , .
,
, ookies
. Cookies , -
"-",
URL, , cookies .
cookies setcookie. :
bool setcookie (string name [, string value [, int expire [, string path
[, string domain [, int secure]]]]])
setcookie:
name cookie;
value , cookie $name;
expire , -
cookie ;
path , cookie;
domain , cookie;
secure , , cookie -
HTPPS. , -
cookie HTTP.
!
cookies : cookie
- ,
cookies . cookies -
- , , .

, cookie, -
$_COOKIE[]. cookie
, , , cookies, -
, , cookies , ,
cookie ( 3.21).

3.21

<?
if(!$cookie)
{
// ,
// cookie
3. 163

header("Location: $PHP_SELF?cookie=1");
// cookie "test"
setcookie("test","1");
}
else
{
if(!$test)
{
echo(" cookies");
}
else
{
// cookie ,
header("Location: http://localhost/test1.php");
}
}
?>

cookies , -
.
, -
.
,
. PHP time mktime -
, .
time , -
. mktime:
int mktime ([int hour [, int minute [, int second [, int month [, int
day [, int year [, int is_dst]]]]]]])
is_dst ,
:
1 ( ; , );
0 ( );
1 ( ).

<?
// cookie 20
setcookie("name", $value, time() + 1200);
// cookie 25 2011
setcookie("name", $value, mktime(0,0,0,01,25,2011));
?>
164 II. -

cookie setcookie
cookie, :
setcookie("param1");
cookie .
cookies , -
, ,
cookie, .
, cookie:
cookies;
;
;
cookies .
.
, , cookie ,
"" , . . cookies
. cookies -
, , /catalog, -
:
setcookie("name", $value, "/catalog/");
/catalog/index.php, /catalog/page.html . .
. ,
cookies :
setcookie("name", $value, "/ catalog /index.php");
, , cookies,
:
setcookie("param1", $value, "/catalog/index.php", ".site.ru");
-
site.ru, mysite.ru, -
.
cookie, ,
HTTP, . . -
, . -
, setcookie -
, :
setcookie("param1", $value, time() + 600, "/catalog/", ".site.ru", 1);

3.2.4.

.
,
. SESSION
3. 165

, ( users
type). xajax- Mainmenu
, id "
" mainmenu .
mainmenu.php 3.22. mainmenu
prgprg prgdiv. prgprg ,
;. prgdiv ,
, ;.
, -
, .
JavaScript ,
.

3.22

function MainMenu($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
//
$query1="SELECT id,name FROM mainmenu WHERE
status='".$_SESSION[type]."' && visible='yes'
ORDER BY sort ASC ";
$rez1=mysql_query($query1);
while($row1=mysql_fetch_assoc($rez1))
{
//
if($row1[id]==$Id)
{
$dataheader3.="&nbsp&nbsp&nbsp&nbsp ".$row1[name];
}
else
//
$dataheader3.="&nbsp&nbsp&nbsp&nbsp<a href='javascript:void(null)'
onclick='
xajax_MainMenu(".$row1[id].");'>".$row1[name]."</a>";
}
//
$objResponse->assign("header3","innerHTML",$dataheader3);
//
$query2="SELECT prgdiv,prgprg,id FROM mainmenu WHERE id=".$Id." ";
$rez2=mysql_query($query2);
$row2=mysql_fetch_row($rez2);
166 II. -

//
$arraydiv=explode(";",$row2[0]);
$arrayprg=explode(";",$row2[1]);
//
for($i=0;$i<count($arrayprg);$i++)
{$divcontent="";$script="";
switch(trim($arrayprg[$i]))
{
//
case "out":
$_SESSION[type]=1;
$query11="SELECT id,name FROM mainmenu WHERE status='1'
&& visible='yes' ORDER BY sort ASC ";
$rez11=mysql_query($query11);$j=0;
while($row11=mysql_fetch_assoc($rez11))
{$j++;
if($j==1)
$divcontent="&nbsp&nbsp&nbsp&nbsp ".$row11[name];
else
$divcontent.="&nbsp&nbsp&nbsp&nbsp <a href='
javascript:void()' onclick='xajax_MainMenu(".$row11[id].")
;'>".$row11[name]."</a>";
}
$query12="SELECT id FROM users
WHERE login='".$_SESSION[session]."' ";
$_SESSION[user]=mysql_result(mysql_query($query12),0);
$script="document.getElementById('flag_time1').
value=".$_SESSION[user].";";
$script.="document.getElementById('header4').innerHTML=
' ';";
break;
case "formvhod": $divcontent="<form name='FormVhod' id='FormVhod'
action='javascript:void(null);' onsubmit='
xajax.$(\"ButtonFormVhod\").disabled=true;
xajax.$(\"ButtonFormVhod\").value=\"...\";
xajax_Vhod(xajax.getFormValues(\"FormVhod\"));'>
<input type='text' id='login' name='login' value=''
size=10 maxlength=10>
<input type='password' id='password'
name='password' value='' size=10 maxlength=10>
<input type='submit' id='ButtonFormVhod' value=' >'>
</form>";
break;
// ()
case "clear": $divcontent="<table></table>";
3. 167

break;
case "clearkorzina": $divcontent="<table></table>";
$script="document.getElementById('flag_korzina').value='no';";
break;
// ()
case "zagadminkategory":$divcontent=f_zag1(
" ");
break;
case "adminkategory":
$divcontent="<div class='menu' id='admin_path_kategory' >
</div><div class='menu' style='margin-left:0'
id='admin_kategory1'>*******</div>";
break;
case "adminopenkategory":
$divcontent=f_admin_open_kategory(1);
break;
case "adminpathkategory":
$divcontent="<b> :</b><br>
".f_string_kategory(1);
$divcontent.="<br><a href='javascript:void();' onclick='
xajax_Delete_Admin_Kategory(1);'></a>";
$divcontent.="<br><a href='javascript:void();' onclick='
xajax_Rename_Admin_Kategory(1);'></a>";
$divcontent.="<br><a href='javascript:void();' onclick='
xajax_Add_Admin_Kategory(1);'></a>";
break;
//
case "zagreg": $divcontent=f_zag1("");
break;
case "reg": $divcontent=f_form_reg_user();
break;
//
case "zagrate": $divcontent=f_zag1(" ");
break;
case "rate": $divcontent=f_view_rate();
break;
//
case "zagkategory": $divcontent=f_zag1("");
break;
case "kategory":
$divcontent="<div class='menu' style='margin-left:0'
id=kategory1></div>";
break;
case "openkategory":
$divcontent=f_open_kategory(1);
168 II. -

break;
// korzina
case "zagkorzina": $divcontent=f_zag1("");
break;
case "korzina": $divcontent=f_korzina_right();
break;
// alltovars
case "zagalltovars": $divcontent=f_zag1(" ");
break;
case "alltovars": $divcontent1=f_view_all_tovars(1);
$divcontent=$divcontent1[0];
break;
case "zagalltovarspage": $divcontent="";
break;
case "alltovarspage": $divcontent1=f_view_all_tovars(1);
$divcontent=$divcontent1[1];
break;
// newtovars
case "zagnewtovars": $divcontent=f_zag1("NEW ");
break;
case "newtovars": $divcontent1=f_view_new_tovars(1);
$divcontent=$divcontent1[0];
break;
case "zagnewtovarspage": $divcontent="";
break;
case "newtovarspage": $divcontent1=f_view_new_tovars(1);
$divcontent=$divcontent1[1];
break;
// tovars
case "zagtovarsaction": $divcontent=f_zag1(" !!!");
break;
case "tovarsaction": $divcontent1=f_view_tovars_action();
$divcontent=$divcontent1;
break;
// search
case "zagsearchtovars": $divcontent=f_zag1(" ");
break;
case "searchtovars": $divcontent1=f_form_search_tovars();
$divcontent=$divcontent1;
break;
// search zakaz
case "zagsearchzakaz": $divcontent=f_zag1(" ");
break;
case "searchzakaz": $divcontent=f_form_search_zakaz();
$script="calendar1=new Epoch('epoch_popup', 'popup',
3. 169

document.getElementById('datazakaz1'));";
$script.="calendar2=new Epoch('epoch_popup','popup',
document.getElementById('datazakaz2'));";
break;
// viewallzakaz
case "zagallzakaz": $divcontent=f_zag1(" ");
break;
case "allzakaz": $divcontent1=f_view_all_zakaz(1);
$divcontent=$divcontent1[0];
break;
case "zagallzakazpage": $divcontent="";
break;
case "allzakazpage": $divcontent1=f_view_all_zakaz(1);
$divcontent=$divcontent1[1];
break;
// search zakaz_admin
case "zagsearchzakaz_admin": $divcontent=f_zag1("
()");
break;
case "searchzakaz_admin": $divcontent=f_form_search_zakaz_admin();
$script="calendar1=new Epoch('epoch_popup','popup',
document.getElementById('datazakaz1'));";
$script.="calendar2=new Epoch('epoch_popup','popup',
document.getElementById('datazakaz2'));";
break;
// viewallzakaz_admin
case "zagallzakaz_admin": $divcontent=f_zag1(" ");
break;
case "allzakaz_admin": $divcontent1=f_view_all_zakaz_admin(1);
$divcontent=$divcontent1[0];
break;
case "zagallzakazpage_admin": $divcontent="";
break;
case "allzakazpage_admin": $divcontent1=f_view_all_zakaz_admin(1);
$divcontent=$divcontent1[1];
break;
// messages + messages_admin
case "zagviewallmessages": $divcontent=f_zag1("
");
break;
case "viewallmessages": $divcontent1=f_view_all_messages_in(1);
$divcontent=$divcontent1[0];
break;
case "zagviewallmessagespage": $divcontent="";
break;
170 II. -

case "viewallmessagespage": $divcontent1=f_view_all_messages_in(1);


$divcontent=$divcontent1[1];
break;
case "zagsearchmessage": $divcontent=f_zag1(" ");
break;
case "searchmessage": $divcontent=f_form_search_message_admin();
$script="calendar1=new Epoch('epoch_popup','popup',
document.getElementById('datazakaz1'));";
$script.="calendar2=new Epoch('epoch_popup','popup',
document.getElementById('datazakaz2'));";
break;
// users
case "zagallusers": $divcontent=f_zag1(" ");
break;
case "allusers": $divcontent1=f_view_all_users(1);
$divcontent=$divcontent1[0];
break;
case "zagalluserspage": $divcontent="";
break;
case "alluserspage": $divcontent1=f_view_all_users(1);
$divcontent=$divcontent1[1];
break;
// search users
case "zagsearchusers": $divcontent=f_zag1(" ");
break;
case "searchusers": $divcontent1=f_form_search_users();
$divcontent=$divcontent1;
break;
// contacts
case "zagcontacts": $divcontent=f_zag1("");
break;
case "contacts": $divcontent1=f_view_contacts();
$divcontent=$divcontent1;
break;
// tovarspartners
case "zagtovarspartners": $divcontent=f_zag1(" ");
break;
case "tovarspartners": $divcontent1=f_tovars_partners();
$divcontent=$divcontent1;
break;
// stat
case "zagstat1": $divcontent=f_zag1("");
break;
case "stat1": $divcontent1=f_stat_site1();
$divcontent=$divcontent1;
3. 171

break;
// info oplata
case "zaginfooplata": $divcontent=f_zag1("");
break;
case "infooplata": $divcontent1=f_info_oplata();
$divcontent=$divcontent1;
break;
}
//
$objResponse->assign($arraydiv[$i],"innerHTML",$divcontent);
// javascript
if(strlen($script)>0)
$objResponse->script($script);
}
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

3.2.5.

,
.
,
. -
mainmenu ( prgprg). -
prgdiv.

(. 3.1 3.3).

3.1.



/
()

zagkategory leftcaption1
kategory left1
openkategory kategory1
"" zagtovarsaction leftcaption2
tovarsaction left2
" " zagrate rightcaption1
172 II. -

3.1 ()



/
()

rate right1
"" zagkorzina rightcaption2
korzina right2
"" zagalltovars centercaption3
alltovars center3
zagalltovarspage centercaption4

alltovarspage center4

" " zagsearchtovars centercaption2
searchtovars center2
lear centercaption5,
center5, centercap-
tion1
clearkorzina center1

"" zagcontacts leftcaption4
rightcaption4
contacts left4, right4
"" zagtovarspartners rightcaption3
tovarspartners right3
"" zagstat1 leftcaption3
stat1 left3
" - zagsearchzakaz centercaption2
"
searchzakaz center2
" - zagallzakaz centercaption3
"
allzakaz center3
" zagallzakazpage centercaption4
"
allzakazpage center4

3. 173

3.1 ()



/
()

lear centercaption5,
center5, centercap-
tion1
clearkorzina center1

"" zagviewallmessages centercaption3
viewallmessages center3
" zagviewallmessagespage centercaption4
"
viewallmessagespage center4

clear centercaption2,
center2, centercap-
tion5, center5, cen-
tercaption1
clearkorzina center1

"" zaginfooplata centercaption2
infooplata center2
clear centercaption3,
center3, centercap-
tion4, center4, cen-
tercaption5, cen-
ter5, centercaption1
clearkorzina center1

"" zagreg centercaption2
reg center2
clear centercaption3,
center3, centercap-
tion4, center4, cen-
tercaption5, cen-
ter5, centercaption1
clearkorzina center1

174 II. -

3.2.



/
()
zagkategory leftcaption1
kategory left1
openkategory kategory1
"" zagtovarsaction leftcaption2
tovarsaction left2
" " zagrate rightcaption1
rate right1
"" zagkorzina rightcaption2
korzina right2
"" zagalltovars centercaption3
alltovars center3
zagalltovarspage centercaption4

alltovarspage center4

" " zagsearchtovars centercaption2
searchtovars center2
lear centercaption5,
center5,
centercaption1
clearkorzina center1

"" zagcontacts leftcaption4
rightcaption4
contacts left4, right4
"" zagtovarspartners rightcaption3
tovarspartners right3
"" zagstat1 leftcaption3
stat1 left3
" - zagsearchzakaz centercaption2
"
searchzakaz center2
3. 175

3.2 ()



/
()
" - Zagallzakaz centercaption3
"
allzakaz center3
" zagallzakazpage centercaption4
"
allzakazpage center4

lear centercaption5,
center5,
centercaption1
clearkorzina center1

"" zagviewallmessages centercaption3
viewallmessages center3
" zagviewallmessages- centercaption4
" page
viewallmessagespage center4


clear centercaption2,
center2, centercap-
tion5, center5, cen-
tercaption1
clearkorzina center1

"" zaginfooplata centercaption2
infooplata center2
clear centercaption3,
center3, centercap-
tion4, center4, cen-
tercaption5, cen-
ter5, centercaption1
clearkorzina center1

out header3
formvhod header2
zagkategory leftcaption1
176 II. -

3.2 ()



/
()
Kategory left1
openkategory kategory1
"" zagtovarsaction leftcaption2
tovarsaction left2
" " zagrate rightcaption1
rate right1
"" zagkorzina rightcaption2
korzina right2
"" zagalltovars centercaption3
alltovars center3
" zagalltovarspage centercaption4
"
alltovarspage center4

" " zagsearchtovars centercaption2
searchtovars center2
clear centercaption5,
center5,
centercaption1
clearkorzina center1

.
, :
, .
3.3.



/
()
zagkategory leftcaption1
kategory left1
openkategory kategory1
3. 177

3.3 ()



/
()
"" Zagtovarsaction leftcaption2
tovarsaction left2
"" zagkorzina rightcaption2
korzina right2
" zagnewtovars centercaption3
"
newtovars center3
" zagnewtovarspage centercaption4

"
newtovarspage center4

" zagsearchtovars centercaption2
"
searchtovars center2
lear centercaption5,
center5,
centercaption1
clearkorzina center1

" zagsearchzakaz_admin centercaption2
"
searchzakaz_admin center2
" zagallzakaz_admin centercaption3
"
- allzakaz_admin center3

" zagallzakaz- centercaption4
" page_admin
allzakazpage_admin center4

lear centercaption5,
center5,
centercaption1
clearkorzina center1

178 II. -

3.3 ()



/
()
"" zagviewallmessages centercaption3
- viewallmessages center3

" zagviewallmessages- centercaption4
" page
viewallmessagespage center4
-

- zagsearchmessage entercaption2

searchmessage enter2
clear centercaption5,
center5,
centercaption1
clearkorzina center1

"- zagadminkategory centercaption3
"
adminkategory center3
adminopenkategory admin_kategory1
adminpathkategory admin_path_kategory
clear centercaption2,
center2,
centercaption4,
center4,
centercaption5,
center5,
centercaption1
clearkorzina center1

zagallusers centercaption3
""
allusers center3
" zagalluserspage centercaption4
-
"
alluserspage center4

3. 179

3.3 ()



/
()

" - zagsearchusers centercaption2


"
searchusers center2
clear centercaption5,
center5,
centercaption1
clearkorzina center1

out header3
formvhod header2
- zagkategory leftcaption1

kategory left1
openkategory kategory1
"" zagtovarsaction leftcaption2
tovarsaction left2
" " zagrate rightcaption1
rate right1
"" zagkorzina rightcaption2
korzina right2
"" zagalltovars centercaption3
alltovars center3
" zagalltovarspage centercaption4
"
alltovarspage center4

" zagsearchtovars centercaption2
"
searchtovars center2
clear centercaption5,
center5,
centercaption1
clearkorzina center1

180 II. -

AJAX -
onclick xajax-,
.

3.3.
3.3.1. ""

,
. "-
" . cookies -
. cookies
($_COOKIE["session"]). "" -
, session_id(), -
" " cookies
. , cookies -
. "" "-
" ,
, . .

. "" ( index.php) -
3.23.

3.23

//
session_start();
//
require_once("mybaza.php");
//
if(isset($_COOKIE["session"]))
{
$_SESSION[session]=$_COOKIE["session"];
$query1="SELECT id FROM users WHERE login='".$_SESSION[session]."' ";
$rez1=mysql_query($query1);
if(mysql_num_rows($rez1)>0)
{
//
// SESSION
$_SESSION[user]=mysql_result($rez1,0);
$_SESSION[type]=1;
}
else
{
3. 181

// ""
$data=date('Y-m-d H:i:s');
$query2="INSERT INTO users SET data='".$data."',
login='".$_SESSION[session]."',
password='',type='1',visible='yes',ip='".f_get_ip().";' ";
mysql_query($query2);
$_SESSION[user]=mysql_insert_id();
$_SESSION[type]=1;
//
//
f_create_message_header4(1,0, $_SESSION[user],
" 50 % ");
//
// ""
f_create_message_header4(2,$_SESSION[user],0,
" ip=".$_SERVER[REMOTE_ADDR]);
}
}
else
{
// ""
$_SESSION[session]=session_id();
$data=date('Y-m-d H:i:s');
$query1="INSERT INTO users SET da-
ta='".$data."',login='".$_SESSION[session]."',
password='',type='1',visible='yes',ip='".f_get_ip().";' ";
mysql_query($query1);
$_SESSION[user]=mysql_insert_id();
$_SESSION[type]=1;
//
//
f_create_message_header4(1,0, $_SESSION[user],"
50 % ");
//
// ""
f_create_message_header4(2,$_SESSION[user],0," -
ip=".$_SERVER[REMOTE_ADDR]);
}
// cookies
setcookie("session",$_SESSION[session],strtotime("now+365 days"));
//
$query01="SELECT vizits FROM users WHERE id='".$_SESSION[user]."' ";
$rez01=mysql_query($query01);
$query02="UPDATE users SET vizits='".(mysql_result($rez01,0)+1)."' WHERE
id='".$_SESSION[user]."' ";
mysql_query($query02);
$_SESSION[ip]=$_SERVER['REMOTE_ADDR'];
182 II. -

3.3.2.


.
(. 3.2).

. 3.2.

prgreg/function_form_reg_user.php ( 3.24) -
. :
my.php define(DISCOUNT,30).
. SMS .


SMS -
SMS. xajax- Popup_Tarif_SMS1,
prgpopup/popup_tarif_sms1.php,
. Popup_Tarif_SMS1 3.24.


SMS
. " -
" AJAX (
, ).
3. 183

3.24

//
function f_form_reg_user()
{
require_once("my.php");
$text1="<center>";
//
// ajax- xajax_Popup_About_Reg (prgpopup/popup_about_reg.php)
$text1.="<br><a href='javascript:void();' onclick='
xajax_Popup_About_Reg();'>
".DISCOUNT." % (
)</a><br><br>";
$text1.="<form id='FormRegUser' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormRegUser\").disabled=true;
xajax.$(\"ButtonFormRegUser\").value=\"...\";
xajax_Reg_User(xajax.getFormValues(\"FormRegUser\"));'>";
$text1.="<table width=100%>";
//
$text1.="<caption> </caption>";
//
// div
//
// onchange
// FormRegUser
$text1.="<tr><td width=50%> (6-12 , )</td>
<td width=30%><input type='text' name='login' id='login'
size='20' maxlength='12' value='' onchange='
xajax_Control_Reg_User(xajax.getFormValues(
\"FormRegUser\"));'></td>
<td width=20%>
<div id='reg_user_login'><font color='red'>no</font></div>
</td></tr>";
//
$text1.="<tr><td width=50%> (6-12)</td>
<td width=30%><input type='password' name='password'
id='password' size='20' maxlength='12' value='' onchange='
xajax_Control_Reg_User(xajax.getFormValues(
\"FormRegUser\"));'></td>
<td width=20%>
<div id='reg_user_password'><font color='red'>
no</font></div>
</td></tr>";
//
$text1.="<tr><td width=50%> </td>
184 II. -

<td width=30%><input type='password' name='password1'


id='password1' size='20' maxlength='12' value='' onchange='
xajax_Control_Reg_User(xajax.getFormValues(
\"FormRegUser\"));'></td>
<td width=20%>
<div id='reg_user_password1'><font color='red'>
no</font></div>
</td></tr>";
// e-mail
$text1.="<tr>
<td width=50%>
e-mail <br>
</td>
<td width=30%><input type='input' name='email' id='email'
size='20' maxlength='30' value='' onchange='
xajax_Control_Reg_User(xajax.getFormValues(
\"FormRegUser\"));'></td>
<td width=20%>
<div id='reg_user_email'><font color='red'>no</font></div>
</td></tr>";
// , SMS-
$text1.="<tr>
<td width=50%>
<br> SMS
<b>".SMS_MESSAGE1."</b>
<b>".SMS_NUMBER1."</b>
, <br>
<a href='javascript:void();' onclick='
xajax_Popup_Tarif_SMS1();'> SMS</a>
</td>
<td width=30% valign='top'><input type='input' name='kod_reg'
id='kod_reg' size='20' maxlength='10' value='' onchange='
xajax_Control_Reg_User(xajax.getFormValues(
\"FormRegUser\"));'></td>
<td width=20% valign='top'>
<div id='reg_user_kod'><font color='red'>no</font></div>
</td></tr>";
$text1.="<tr><td></td>
<td>
<input type='submit' id='ButtonFormRegUser'
value=' ->' disabled=true>
</td>
<td></td></tr>";
$text1.="</table>";
$text1.="</form>";
3. 185

return $text1;
}

//////// - //////////////
function Popup_Tarif_SMS1()
{
$objResponse = new xajaxResponse();
require_once("mybaza.php");
$objResponse->assign("windowdop","style.display","none");

$text1.="<a href='javascript:void(null);' onclick='


document.getElementById(\"windowdop\").style.display=
\"none\";return false;'>
<img src='img/delete.png' align=right></a>";
$text1.="<br><br><center> sms 1161
</center><table>";
//
$ff1=fopen("tarif_sms_1161.csv","r");
$text1.="<tr><td></td><td> SMS , .</td></tr>";
while(!feof($ff1))
{
$line1=fgets($ff1,1024);
$arrline1=explode(";",$line1);
$text1.="<tr><td>".$arrline1[2]."</td><td>".$arrline1[5]."</td></tr>";
}
$text1.="</table>";

$objResponse->script("document.getElementById(
'windowdop').style.display='block'");
$objResponse->assign("windowdop","innerHTML",$text1);
$objResponse->script("document.getElementById(
'windowdop').scrollIntoView();");

return $objResponse;
}

.
.
AJAX- xajax_Control_Reg_User ( prgreg/control_reg_user.php) -
FormRegUser:
onchange='xajax_Control_Reg_User(xajax.getFormValues"FormRegUser"))'
E-mail . SMS
a1agregator ( oplata_reg)
, SMS-. -
, oplata_reg
186 II. -

active=yes ID .
,
(. 3.3). SMS
a1agregator . 3.4. Control_Reg_User
prgreg/control_reg_user.php ( 3.25).

. 3.3. SMS-

3.25

//
//
function Control_Reg_User($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
$query1="SELECT id FROM users WHERE login='".utftowin($Id[login])."' ";
$rez1=mysql_query($query1);
$count=0;
// login
// , 6-12
if(mysql_num_rows($rez1)>0)
$objResponse->assign("reg_user_login","innerHTML","<font
3. 187

color='red'> </font>");
elseif(!ereg("^([a-z,A-Z,-,-,0-9]{6,12})$",$Id[login]))
$objResponse->assign("reg_user_login","innerHTML","<font
color='red'>ERR</font>");
else
{
$objResponse->assign("reg_user_login","innerHTML","<font
color='blue'></font>");
$count++;
}
// password - , 6-12
if(!ereg("^([a-z,A-Z,-,-,0-9]{6,12})$",$Id[password]))
$objResponse->assign("reg_user_password","innerHTML","<font
color='red'>ERR</font>");
else
{
$objResponse->assign("reg_user_password","innerHTML",
"<font color='blue'></font>");
$count++;
}
// password1 password
if(utftowin($Id[password1])==utftowin($Id[password]) &&
strlen($Id[password1])>0)
{
$objResponse->assign("reg_user_password1","innerHTML","<font
color='blue'></font>");
$count++;
}
elseif(strlen(trim($Id[password1]))==0)
{
$objResponse->assign("reg_user_password1","innerHTML","<font
color='red'>no</font>");
$count++;
}
else
{
$objResponse->assign("reg_user_password1","innerHTML","<font
color='red'><>password!</font>");
}
// email
if(ereg("^([a-z,0-9,-_\.]{2,20})([\@]{1})([a-z,0-9,-_]{2,20})([\.]
{1})([a-z,]{1,3})$",$Id[email]))
{
$objResponse->assign("reg_user_email","innerHTML","<font
color='blue'></font>");
188 II. -

$count++;
}
else
$objResponse->assign("reg_user_email","innerHTML","<font
color='red'>ERR</font>");
// kod_reg
$query2="SELECT * FROM oplata_reg WHERE kod_reg='".$Id[kod_reg]."' ";
$rez2=mysql_query($query2);
$row2=mysql_fetch_assoc($rez2);
if(mysql_num_rows($rez2)==0)
$objResponse->assign("reg_user_kod","innerHTML","<font
color='red'> </font>");
elseif($row2[activ]=='yes')
{
$message=' '.$row2[data].' ';
$objResponse->assign("reg_user_kod","innerHTML","<font
color='red'>".$message."</font>");
}
else
{
$objResponse->assign("reg_user_kod","innerHTML","<font
color='blue'></font>");
$count++;
}

// ?
if($count==5)
$objResponse->assign("ButtonFormRegUser","disabled",false);
else
$objResponse->assign("ButtonFormRegUser","disabled",true);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}


. xajax_Reg_User
( prgreg/reg_user.php), (
users) e-mail, . -
. 3.4. Reg_User
prgreg/reg_user.php ( 3.26).

3.26

//
function Reg_User($Id)
3. 189

{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
require_once("my.php");
$login=utftowin($Id[login]);
$password=utftowin($Id[password]);
$email=$Id[email];
$data=date('Y-m-d H:i:s');
$query1="INSERT INTO users SET data='".$data."',
login='".$login."',password='".$password."',
type='2',visible='yes',discount='".DISCOUNT."',
email='".$email."',ip='".f_get_ip().";' ";
//
$rez1=mysql_query($query1);
if($rez1)
{
$id=mysql_insert_id();
//
$text1="<center><br><br> !!!<br><br>
email ".$email."<br><br>
<a href='javascript:void();' onclick='
document.getElementById(\"login\").value=\"".$login."\";
document.getElementById(\"password\")
.value=\"".$password."\";
document.getElementById(\"ButtonFormVhod\").disabled=true;
document.getElementById(\"ButtonFormVhod\").
value=\"...\";
xajax_Vhod(xajax.getFormValues(\"FormVhod\"));
'></a>
</center>";
// sms
$query2="UPDATE oplata_reg SET id_user='".$id."',
data='".date('Y-m-d H:i:s')."',activ='yes'
WHERE kod_reg='".$Id[kod_reg]."' ";
mysql_query($query2);
// e-mail
$to=$email;
$subject=' '.SITE;
$body='<b> '.SITE.'<b><br>';
$body.='<b> <b>'.SITE.'<br>';
$body.=' : <br>';
$body.='<b> - <b>'.$login.'<br>';
$body.='<b> - <b>'.$password.'<br>';
190 II. -

$body.='<br>';
$body.=' '.SITE.'<br>';
$body.='email - <a href=mailto:'.EMAILADMIN.'
>'.EMAILADMIN.'</a><br>';
$headers="Content-type: text/html; charset=windows-1251;";
mail($to,$subject,$body,$headers);
}
else
{
$text1="<center><br><br> !!!<br>
<br> </center>";
}
$objResponse->assign("center2","innerHTML",$text1);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}

. 3.4.

3.4. SMS a1agregator


SMS- a1agregator.ru.
http://www.a1agregator.ru . -
, , . 3.5.
3. 191

. 3.5. a1agregator

. 3.6.

, . .
. -
.
""
.
192 II. -

VIP-.
-
. -
( 1 API). A1 API
(. 3.6).
, -
(. 3.7).

. 3.7.

-: -
, - .
. . -

(. 3.8). , .
.
, SMS-: ,
. , -
, (
).
, . -
( ).
, MD5
3. 193

GET-.
, -
1 API. -
.
, , -
.
-,
.

. 3.8.

SMS- ,
a1agregator , URL (
http://goodtovars.ru/prgreg/sms.php).
prgreg/sms.php 3.27.
:
http://goodtovars.ru/prgreg/sms.php?user_id=79283456789&num=1161&cost=
100&cost_rur=100&msg=1%2Bregs&skey=d41d8cd98f00b204e9800998ecf8427e&opera
tor_id=112&date=2010-04-22+12%3A10%3A05& smsid=1282022226&msg_trans=1%
2Bregs&operator=operator&
test=1&ran=5&try=1&country_id=4846&sign=74fb9b1b1535ae4ee02a606b541f1812
:
user_id SMS;
num (1161);
msg (1+reg);
194 II. -

cost ;
smsid ID a1agregator (1282022226).
URL- :
smsid:1282022226\nstatus:ignore\n";

smsid1282022226\nstatus:reply\nkod:\n\n
:
;
, ,
, .

3.27

<?
//
require_once("../my.php");
//
require_once("../mybaza.php");
//
if( $_GET['num']!=SMS_NUMBER1 || $_GET['msg_trans']!=SMS_MESSAGE1 )
{
//
$smsid = $_GET['smsid'];
//
echo "smsid:$smsid\n";
echo "status:ignore\n";
}
//
//
else
{
$password= $_GET['smsid'];
$smsid = $_GET['smsid'];
echo "smsid:$smsid\n";
echo "status:reply\n";
echo "kod:$password\n";
echo "\n";
echo "Usluga oplachena.Kod=".$password."\n";
$query1="INSERT INTO oplata_reg SET data='".date("Y-m-d H:i:s")."',kod_
reg='".$_GET['smsid']."',
phone='".$_GET['user_id']."',activ='no' ";
$rez1=mysql_query($query1);
}
?>
3. 195

3.5. ""
"" :
;
;
;
;
.

. ,
. -
( ).
.

3.5.1.

.
kategory. :
id ;
id_parent ID (0 );
name ;
nn ;
visible (yes ; no ).
. 3.9.

. 3.9.

( ) -
.
(xajax_Close_Kategory); (xajax_Open_Kategory):
; -
(xajax_View_Tovars_Kategory); . . -
196 II. -

, . -
id=kategoryN (id ID -
). , -
. 3.10.

. 3.10.

( )
. -
. , (), -
prgtovars/open_close_kategory.php ( 3.28).

3.28

//
function Open_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_open_kategory($Id);
//
$objResponse->assign("kategory".$Id,"innerHTML",$content);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
3. 197

}
//
function Close_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_close_kategory($Id);
//
$objResponse->assign("kategory".$Id,"innerHTML",$content);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}

, , prgtovars/function_open_
close_kategory.php ( 3.29).

3.29

///
//
function f_open_kategory($Id)
{
require_once("mybaza.php");
$text1="";
//
$query1="SELECT name,id,nn FROM kategory WHERE id='".$Id."'
&& visible='yes' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<a href='javascript:void();' onclick='xajax_Close_Kategory
(".$Id.")'><img src='img/close_dir.ico'></a>
<a href='javascript:void();'
onclick='xajax_Close_Kategory(".$Id.")'>
".$row1[name]." (".$row1[nn].")</a>";
$query2="SELECT name,id,nn FROM kategory WHERE id_parent='".$Id."'
&& visible='yes' ";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_assoc($rez2))
{
$query3="SELECT id FROM kategory WHERE id_parent='".$row2[id]."'
&& visible='yes' ";
$rez3=mysql_query($query3);
// ,
if(mysql_num_rows($rez3)>0)
198 II. -

{
$text1.="<div class='menu' id='kategory".$row2[id]."'>
<span><a href='javascript:void();' onclick='
xajax_Open_Kategory(".$row2[id].")'>
<img src='img/open_dir.ico'></a></span>
<span><a href='javascript:void();' onclick='
xajax_Open_Kategory(".$row2[id].")'>
".$row2[name]." (".$row2[nn].")</a><span></div>";
}
//
else
{
$text1.="<div class='menu' id='kategory".$row2[id]."'>
<a href='javascript:void();' onclick='
var x=new Array();x[0]=".$row2[id].",x[1]=1;
xajax_View_Tovars_Kategory(x)'>
<img src='img/last_dir.ico'></a>
<a href='javascript:void();' onclick='
var x=new Array();x[0]=".$row2[id].",x[1]=1;
xajax_View_Tovars_Kategory(x)'>
".$row2[name]." (".$row2[nn].")</a></div>";
}
}
return $text1;
}
//
function f_close_kategory($Id)
{
require_once("mybaza.php");
$text1="";
//
$query1="SELECT name,id,nn FROM kategory WHERE id='".$Id."'
&& visible='yes' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<a href='javascript:void();' onclick='
xajax_Open_Kategory(".$Id.")'>
<img src='img/open_dir.ico'></a>
<a href='javascript:void();' onclick='
xajax_Open_Kategory(".$Id.")'>
".$row1[name]." (".$row1[nn].")</a>";

return $text1;
}
3. 199

3.5.2.
center2
(. 3.11).
:
;
;
;
;
( ); ;
( );
( );
;
( ).
View_Tovars_Kategory, , -
prgtovars/view_tovars_kategory.php ( 3.30). -
id .

3.30

<?php
function View_Tovars_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$zag=f_zag1(f_string_kategory($Id[0]));
$objResponse->assign("centercaption3","innerHTML",$zag);
//
//
$content=f_view_tovars_kategory($Id);
$objResponse->assign("center3","innerHTML",$content[0]);
$objResponse->assign("center4","innerHTML",$content[1]);
// div center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
200 II. -

View_Tovars_Kategory ( prgtovars/view_tovars_kategory.php)
:
center2 ( );
center3 ( );
center4 .
. 3.11. , -
, prgtovars/function_view_tovars_ kategory.php (-
3.31).

. 3.11.

3.31

<?php
//
//
// $Id[0] - id
// $Id[1] -
function f_view_tovars_kategory($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
3. 201

//
//
require_once("prgtovars/function_string_kategory.php");
//
$query0="SELECT COUNT(id) FROM tovars WHERE
id_kategory='".$Id[0]."' && visible='yes' ";
$rez0=mysql_query($query0);
$count=mysql_result($rez0,0);
//
// NN1 ( my.php)
$pages=ceil($count/NN1);
$page=min($Id[1],$pages);
$poz=($page-1)*NN1;
// ($count>0), .
// $text=' ';
if($count>0)
{
//
// NN1, poz
$query1="SELECT * FROM tovars WHERE id_kategory='".$Id[0]."'
&& visible='yes' LIMIT ".$poz.", ".NN1."";
$rez1=mysql_query($query1);
while($row1=mysql_fetch_assoc($rez1))
{
//
$text1.="<div class='zag_tovar'><span
onmousedown='var x=document.getElementById(\"windowdrag\");
x.style.visibility=\"visible\";
var y=\"".$row1[name]."\";x.innerHTML=y;
flag1.status=1;flag1.id=".$row1[id].";return false;'>
".$row1[name]."</span></div>";
$text1.="<div class='kategory_tovar'>".f_string_kategory
($row1[id_kategory])."</div>";
$text1.="<div class='info_tovar'>";
//
$text1.="<table><tr><td width=20%><img src='resize_100.php?
pic=".$row1[img]."' onmousedown='var x=document.getElementById
(\"windowdrag\");x.style.visibility=\"visible\";
var y=\"<img src=resize_100.php?pic=".$row1[img].">
\";x.innerHTML=y;
flag1.status=1;flag1.id=".$row1[id].";return false;'></td>";
//
$text1.="<td width=80%>".$row1[info]."</td></tr></table>";
$text1.="</div>";
//
202 II. -

//
if($row1[new_pay_rub]>0)
{
$text1.="<div class='no_pay_tovar'> - ".$row1[pay_rub]."
.</div>";
$text1.="<div class='new_pay_tovar'>.
".$row1[new_pay_rub]." .</div>";
}
//
else
$text1.="<div class='pay_tovar'> - ".$row1[pay_rub]."
.</div>";
//
$query2="SELECT discount FROM users WHERE
id='".$_SESSION[user]."' ";
$text1.="<div class='discount_tovar'> - ".
mysql_result(mysql_query($query2),0)." %</div>";
//
$text1.="<div>
<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Add_To_Korzina(".$row1[id].");'>
</a>
( drag&drop img )</div>
<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_View_Tovar(".$row1[id].");'>
</a>
</div>";
//
if($_SESSION[type]>7)
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Edit_Tovar(".$row1[id].");'>
</a>
</div>";
$text1.="<div class='linedown_tovar'><hr></hr></div>";
$text1.="</div>";
}
//
if($_SESSION[type]>7)
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Add_New_Tovar();'> </a>
</div>";
3. 203

//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x[0]=".$Id[0].";x[1]=".($page-1).";
xajax_View_Tovars_Kategory(x);'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,2);
for($i=0;$i < count($x);$i++)
//for($i=1;$i <= $pages;$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x[0]=".$Id[0].";x[1]=".$x[$i].";
xajax_View_Tovars_Kategory(x);'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x[0]=".$Id[0].";x[1]=".($page+1).";
xajax_View_Tovars_Kategory(x);'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count." - ".$pages."<br>
</center>";}
else
{$text2.="</center>";}
}
}
//
else
{
$text1="<br><center>
</center><br>";
}
// -
$text[0]=$text1;
204 II. -

// -
$text[1]=$text2;
return $text;
}
?>

( NN1) my.php
(define(NN1,5);).

. -

<img src=resize_100.php?pic=".$row1[img].">.
PHP GD2.

, -
, .
( )
.

3.5.3. ""
""
100 px .
PHP- GD2.
"" .
resize_100.php ( 3.32).

3.32

<?php
if($_GET['pic'])
{
$img = new img($_GET['pic']);
$img->resize();
$img->show();
}
class img {
var $image = '';
var $temp = '';
function img($sourceFile)
{
if(file_exists($sourceFile))
{
$pictype=strchr($sourceFile,".");
if ($pictype==".png")
$this->image = ImageCreateFromPNG($sourceFile);
3. 205

if ($pictype==".gif")
$this->image = ImageCreateFromGIF($sourceFile);
if ($pictype==".jpg")
$this->image = ImageCreateFromJPEG($sourceFile);
}
else
{
$this->errorHandler();
}
return;
}
// resize
function resize($width = 100, $height = 100, $aspectradio = true)
{
$o_wd = imagesx($this->image);
$o_ht = imagesy($this->image);
if(isset($aspectradio)&&$aspectradio)
{
$w = round($o_wd * $height / $o_ht);
$h = round($o_ht * $width / $o_wd);
if(($height-$h)<($width-$w))
{
$width =& $w;
}
else
{
$height =& $h;
}
}
$this->temp = imageCreateTrueColor($width,$height);
imageCopyResampled($this->temp, $this->image,
0, 0, 0, 0, $width, $height, $o_wd, $o_ht);
$this->sync();
return;
}
function sync()
{
$this->image =& $this->temp;
unset($this->temp);
$this->temp = '';
return;
}
function show()
{
$this->_sendHeader();
206 II. -

ImageJPEG($this->image);
return;
}

function _sendHeader()
{
header('Content-Type: image/jpeg');
}
function errorHandler()
{
echo "error";
exit();
}
function store($file)
{
ImageJPEG($this->image,$file);
return;
}
function watermark($pngImage, $left = 0, $top = 0)
{
ImageAlphaBlending($this->image, true);
$layer = ImageCreateFromPNG($pngImage);
$logoW = ImageSX($layer);
$logoH = ImageSY($layer);
ImageCopy($this->image, $layer, $left, $top, 0, 0, $logoW, $logoH);
}
}
?>

3.5.4.
.
( ) -
, ()
. . 3.12 3.13. 20,
, . -

< 1 2 3 .. n-2 n-1 n n+1 n+2 .. last-2 last-1 last >
. . , n , n , n
(n ).
dopfun.

doarray1 ( dopfun.php).
[1,2,3,,7,8,9,,13,14,15] .
|__k_|
3. 207

. 3.12.

. 3.13.

dopfun doarray1 dopfun.php ( 3.33).

3.33

//
//1,2..k1,k2,k3,k4..n-1,n
// arg1 - .
// arg2 - -
// arg3 k
function doarray1($arg1,$arg2,$arg3)
{
$y=array();
208 II. -

if($arg2<=($arg3+4)) //
{
for($j=0;$j<$arg2;$j++)
$y[$j]=$j+1;
}
else
{
if($arg1<=$arg3+2) // 11121....11111
{
for($j=0;$j<($arg3+2);$j++)
$y[$j]=$j+1;
$y[$j]="...";$j++;
$y[$j]=$arg2-1;$j++;
$y[$j]=$arg2;
}
elseif($arg1>($arg2-$arg3-2)) // 1111.....11211
{
$y[0]=1;
$y[1]=2;
$y[2]="...";
for($j=3;$j<($arg3+5);$j++)
$y[$j]=$arg2-$arg3+$j-4;
}
else // 11..112111...11
{
$y[0]=1;
$y[1]=2;
$y[2]="...";
for($j=3;$j<=($arg3+3);$j++)
$y[$j]=$arg1+$j-4;
$y[$j]="...";$j++;
$y[$j]=$arg2-1;$j++;
$y[$j]=$arg2;
}
}
return $y;
}

3.5.5.

(. 3.14). -
f_string_kategory prgtovar/function_string_
kategory.php ( 3.34).
3. 209

3.34

<?php
//
function f_string_kategory($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text1="";
$query0="SELECT * FROM kategory WHERE id='".$Id."'";
$rez0=mysql_query($query0);
$row0=mysql_fetch_assoc($rez0);
$text1=$text1.$row0[name];
$id_parent=$row0[id_parent];
//
while($id_parent>0)
{
$query0="SELECT * FROM kategory WHERE id='".$id_parent."'";
$rez0=mysql_query($query0);
$row0=mysql_fetch_assoc($rez0);
$text1=$row0[name]."->".$text1;
$id_parent=$row0[id_parent];
}
return $text1;
}
?>

. 3.14.

: ID -
, ,
, , -
.
210 II. -

3.5.6.

function_form_search_tovars.php.
(. 3.15). id = FormSearchTovars.
:
input type='hidden' id='pagesearch' name='pagesearch' value='1'>

. 3.15.

f_form_search_tovar
prgtovars/function_form_search_tovar.php ( 3.35).

3.35

<?php
//
function f_form_search_tovars()
{
//
require_once("my.php");
//
require_once("mybaza.php");
//
$text1.="<form id='FormSearchTovars' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormSearchTovars\").disabled=true;
xajax.$(\"ButtonFormSearchTovars\").value=\"...\";
xajax_View_Search_Tovars(xajax.getFormValues(
\"FormSearchTovars\"));'>";
$text1.="<table width=100%>";
$text1.="<tr><td width=50%></td>";
$text1.="<td width=50%>
<input type='text' name='name' value='' size=20 maxlength=20>
<input type='hidden' id='pagesearch' name='pagesearch'
value='1'></td></tr>";
$text1.="<tr><td width=50%> </td>";
$text1.="<td width=50%>
3. 211

<input type='checkbox' name='inname' value='1' checked>



<br><input type='checkbox' name='ininfo' value='1' >
</td></tr></table>";
$text1.="<center><input type='submit' id='ButtonFormSearchTovars'
value=' ->'></center>";
$text1.="</form>";
return $text1;
}
?>

xajax_View_Search_Tovars.
View_Search_Tovars ( prgtovars/view_tsearch_tovars.php) -
:
center2 ( );
center3 ( );
center4 .
. 3.16.

. 3.16.

View_Search_Tovars, , -
prgtovars/view_search_tovars.php ( 3.36). -
ID .
212 II. -

3.36

<?php
//
function View_Search_Tovars($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$zag=f_zag1(" ");
$objResponse->assign("centercaption3","innerHTML",$zag);
//
$content=f_view_search_tovars($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
//
$objResponse->assign("ButtonFormSearchTovars","value", " ->");
$objResponse->assign("ButtonFormSearchTovars","disabled", false);

$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

f_view_search_tovars, ,
prgtovars/function_view_search_tovars.php ( 3.37). -
. .
. -
NN1 my.php.
($count>0), .
(. 3.17). SQL-.
SQL- WHERE
, .
,
. LIKE %string% SQL-
.
:
;
;
3. 213

;
;
( ); ;
( );
( );
;
( ).

. 3.17.

3.37

<?php
function f_view_search_tovars($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
//
//
require_once("prgtovars/function_string_kategory.php");
$text=array();
$text1="";
//
$query0="SELECT COUNT(id) FROM tovars WHERE visible='yes' ";
$name=utftowin($Id[name]);
if(strlen(rtrim(ltrim($name)))>0)
{
if($Id[inname]==1 && $Id[ininfo]==1)
$query0.="&& (name LIKE '%".$name."%' || info LIKE '%".$name."%') ";
elseif($Id[inname]==1)
$query0.="&& name LIKE '%".$name."%' ";
214 II. -

elseif($Id[ininfo]==1)
$query0.="&& info LIKE '%".$name."%' ";
else
;
}
$rez0=mysql_query($query0);
//
$count=mysql_result($rez0,0);
//
$pages=ceil($count/NN1);
//
$page=min($Id[pagesearch],$pages);$poz=($page-1)*NN1;
$text1="<div class='zag_view_tovars'>";
//
if($count>0)
{
$query0.=" LIMIT ".$poz.", ".NN1."";
$query1=str_replace("COUNT(id)","*",$query0);
$rez1=mysql_query($query1);
while($row1=mysql_fetch_assoc($rez1))
{
//
$text1.="<div class='zag_tovar'><span onmousedown='
var x=document.getElementById(\"windowdrag\");
x.style.visibility=\"visible\";
var y=\"".$row1[name]."\";x.innerHTML=y;
flag1.status=1;flag1.id=".$row1[id].";return false;'
>".$row1[name]."</span></div>";
//
$text1.="<div class='kategory_tovar'>".f_string_kategory(
$row1[id_kategory])."</div>";
$text1.="<div class='info_tovar'>";
//
$text1.="<table><tr><td width=20%><img src='resize_100.php?
pic=".$row1[img]."' onmousedown='
var x=document.getElementById(\"windowdrag\");
x.style.visibility=\"visible\";
var y=\"<img src=resize_100.php? pic=".$row1[img].">\";
x.innerHTML=y;flag1.status=1; flag1.id=".$row1[id].";
return false;'></td>";
//
$text1.="<td width=80%>".$row1[info]."</td></tr></table>";
$text1.="</div>";
//
if($row1[new_pay_rub]>0)
3. 215

{
$text1.="<div class='no_pay_tovar'>
- ".$row1[pay_rub]." .</div>";
$text1.="<div class='new_pay_tovar'>
. - ".$row1[new_pay_rub]." .</div>";
}
//
else
$text1.="<div class='pay_tovar'>
- ".$row1[pay_rub]." .</div>";
//
$query2="SELECT discount FROM users WHERE id='".$_SESSION[user]."'";
$text1.="<div class='discount_tovar'> - ".
mysql_result(mysql_query($query2),0)." %</div>";
//
$text1.="<div>
<div class='function_tovar'>
<a href='javascript:void()'
onclick='xajax_Add_To_Korzina(".$row1[id].");'>
</a>
( drag&drop img )</div>
<div class='function_tovar'>
<a href='javascript:void()'
onclick='xajax_View_Tovar(".$row1[id].");'></a>
</div>";
//
if($_SESSION[type]>7)
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Edit_Tovar(".$row1[id].");'></a>
</div>";
$text1.="<div class='linedown_tovar'><hr></hr></div>";
$text1.="</div>";
}
//
if($_SESSION[type]>7)
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Add_New_Tovar();'> </a>
</div>";
//
$text2="";
if($pages>1)
{
if($page != 1)
216 II. -

{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchTovars.pagesearch.value=".$i.";
xajax_View_Search_Tovars(xajax.getFormValues
(\"FormSearchTovars\"));'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,2);
for($i=0;$i < count($x);$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchTovars.pagesearch.value=".$x[$i].";
xajax_View_Search_Tovars(xajax.getFormValues
(\"FormSearchTovars\"));'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchTovars.pagesearch.value=".$i.";
xajax_View_Search_Tovars(xajax.getFormValues
(\"FormSearchTovars\"));'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count." - ".$pages."<br>
</center>";}
else
{$text2.="</center>";}
}
}
//
else
{
$text2="<br><center>
</center><br>";
}
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>
3. 217



xajax- View_Search_Tovars
pagesearch.

3.5.7.
View_Tovar, , prgto-
vars/view_tovar.php ( 3.38). ID .
ID , .
, . ,
. 3.5.6, .

3.38

<?php
function View_Tovar($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_tovar($Id);
$objResponse->assign("center5","innerHTML",$content);
//
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
// center5
$objResponse->script("document.getElementById(
'center5').scrollIntoView();");

$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
. 3.18.

,
, ( ).
.

f_view_tovar, , prgtovars/
function_view_tovar.php ( 3.39).
218 II. -

. 3.18.

3.39

<?php
//
// $Id - id
function f_view_tovar($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
//
//
require_once("prgtovars/function_string_kategory.php");
//
$query1="SELECT * FROM tovars WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
//
$text1.="<div class='zag_tovar'>".$row1[name]."</div>";
//
$text1.="<div class='kategory_tovar'>
".f_string_kategory($row1[id_kategory])."</div>";
//
if($row1[img]!='imgtovar/nofoto.gif')
$text1.="<div><img src='".$row1[img]."' width=200px></div>";
3. 219

//
$text1.="<div class='fullinfo_tovar'>".$row1[fullinfo]."</div>";
//
if($row1[new_pay_rub]>0)
{
$text1.="<div class='no_pay_tovar'> - ".$row1[pay_rub]."
.</div>";
$text1.="<div class='new_pay_tovar'>.
".$row1[new_pay_rub]." .</div>";
}
//
else
$text1.="<div class='pay_tovar'> - ".$row1[pay_rub]." .</div>";
//
$query2="SELECT discount FROM users WHERE id='".$_SESSION[user]."' ";
$text1.="<div class='discount_tovar'> - ".
mysql_result(mysql_query($query2),0)." %</div>";

$text1.="<div>";
//
if($row1[visible]=='yes')
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Add_To_Korzina(".$row1[id].");'> </a>
</div>";
if($_SESSION[type]>7)
{
//
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Edit_Tovar(".$row1[id].");'></a>
</div>";
if($row1[visible]=='yes')
//
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_DoHidden_Tovar(".$row1[id].");'></a>
</div>";
//
else
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_DoVisible_Tovar(".$row1[id].");'></a>
</div>";
//
220 II. -

if($row1[visible]!='del')
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Delete_Tovar(".$row1[id].");'></a>
</div>";
}
$text1.="<div class='linedown_tovar'><hr></hr></div>";
$text1.="</div>";
return $text1;
}
?>

3.5.8. ( )
( -
). -
.
. -
"" id=left2 (. 3.19).

. 3.19.

f_view_tovar, , prgtovars/
function_ view_tovars_action.php ( 3.40).

3.40

<?php
//
//
function f_view_tovars_action()
{
3. 221

require_once("my.php");
require_once("mybaza.php");
$text1="";
$query1="SELECT * FROM tovars WHERE new_pay_rub>0 && visible='yes'
ORDER BY data DESC LIMIT 0, 5 ";
$rez1=mysql_query($query1);
if(mysql_num_rows($rez1)>0)
{
while($row1=mysql_fetch_assoc($rez1))
{
$text1.="<div class='zag_tovar_action'><span
onmousedown='var x=document.getElementById(\"windowdrag\");
x.style.visibility=\"visible\";
var y=\"".$row1[name]."\";x.innerHTML=y;
flag1.status=1;flag1.id=".$row1[id].";
return false;'>".$row1[name]."</span></div>";
$text1.="<div><span class='no_pay_tovar1'>
".$row1[pay_rub]."</span>";
$text1.="<span class='new_pay_tovar1'> - ".$row1[new_pay_rub]."
.</span></div>";
$text1.="<div>
<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Add_To_Korzina(".$row1[id].");'> </a>
</div>
<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_View_Tovar(".$row1[id].");'></a>
</div>";
if($_SESSION[type]>7)
$text1.="<div class='function_tovar'>
<a href='javascript:void()' onclick='
xajax_Edit_Tovar(".$row1[id].");'></a>
</div>";
$text1.="<div class='linedown_tovar'><hr></hr></div>";
}
}
else
{
$text1="<br><center> </center><br>";
}
return $text1;
}
?>
222 II. -

, , -
( ).
, , -
.

3.6.
.
cookies $_SESSION. -
f-$_SESSION[session].txt.
session_id() (SID).
tmp1. -
, . . , -
. -
.

3.6.1.
f_korzina_right. -
f-$_SESSION[session].txt. ,
(), . f_korzina_right
prgkorzina/function_ korzina_right.php ( 3.41).

3.41

<?php
//
// -
function f_korzina_right()
{
//
require_once("mybaza.php");
$text1="";
//
$file1="tmp1/f-".$_SESSION[session]."-".$_SESSION[user].".txt";
// -
if(!file_exists($file1))
{
$fp=fopen($file1,"w");chmod($file1,0777);
$count=0;$kol=0;$summa=0;
}
// , -
else
{
$fp=fopen($file1,"r");
3. 223

$count=0;$summa=0;
while($str=fgetcsv($fp,1000,";"))
{
$count++;
$kol+=$str[1];
$summa+=$str[1]*$str[2];
}
}
$text1.="<center><img id='imgkorzina'
onmouseover='flag1.over=1;' onmouseout='flag1.over=0;'
src='img/korzina.jpg'><br>";
if($count>0) //
{
$text1.="<br> - ".$count;
$text1.="<br>- - ".$kol;
$text1.="<br>".$summa." rub";
$query1="SELECT usd,eur FROM rate ORDER BY data DESC LIMIT 0, 1 ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$usd=$row1[usd];$eur=$row1[eur];
$text1.="<br>".sprintf("%8.2f",$summa/$usd)." usd";
$text1.="<br>".sprintf("%8.2f",$summa/$eur)." eur";
$text1.="<br><a href='javascript:void();' onclick='xajax_View_
Korzina();'></a>";
}
else //
{
$text1.="<br> ";
}
$text1.="<center>";
return $text1;
?>

:
;
;
.
. 3.20 3.21.
: ID ; -
; .
( -
) xajax- Add_To_Korzina ( -
prgkorzina /add_to_korzina.php, 3.42).
ID . .
224 II. -

_add_to_korzina, prgkorzina
/function_add_to_korzina.php ( 3.43). -
. -
, .

. 3.20.

. 3.21.

3.42

<?php
//
function Add_To_Korzina($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_add_to_korzina($Id);
3. 225

if($content=='no')
{
//
$content1=f_korzina_right();
// javascript
//
$script2="if(document.forms.Flags.flag_korzina.value=='yes')";
$script2.="{xajax_View_Korzina();}";
$objResponse->script($script2);
$objResponse->assign("right2","innerHTML",$content1);
//
$objResponse->script("document.getElementById
('right2').scrollIntoView();");
}
else
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

3.43

<?php
function f_add_to_korzina($Id)
{
$text1="no";
//
require_once("mybaza.php");
//
$file1="tmp1/f-".$_SESSION[session]."-".$_SESSION[user].".txt";
$fp=fopen($file1,"r");
$tofile='';$kol=1;
//
while($str=fgetcsv($fp,1000,";"))
{
$tofile1=implode($str,";")."\r\n";
//
if($str[0]==$Id)
{
$text1='yes';
$kol=$str[1]+1;
}
//
//
226 II. -

else
$tofile.=$tofile1;
}
//if($text1=='no')
//{
$query1="SELECT pay_rub,new_pay_rub FROM tovars WHERE id=".$Id." ";
$query2="SELECT discount FROM users WHERE id='".$_SESSION[user]."' ";
$discount=mysql_result(mysql_query($query2),0);
if(mysql_result(mysql_query($query1),0,"new_pay_rub")>0)
$pay_rub=mysql_result(mysql_query($query1),0,"new_pay_rub");
else
$pay_rub=mysql_result(mysql_query($query1),0,"pay_rub");
//
$pay_rub=trim(sprintf("%10.2f",$pay_rub*(100-$discount)/100));
//
$tofile.=$Id.";".$kol.";".$pay_rub."\r\n";
//}
fclose($fp);
//
$fp=fopen($file1,"w");
fwrite($fp,$tofile);
fclose($fp);
return $text1;
}
?>


3.43 ,
, ,
(. 3.22).

. 3.22.
3. 227

3.6.2.
.
, , ,
, . -
(. 3.23). -
xajax- View_Korzina ( prgkorzina /view_korzina.php,
3.44).

. 3.23.

3.44

<?php
function View_Korzina()
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content2=f_view_korzina();
$zagcontent2=" <a href='javascript:void();' onclick='";
zagcontent2.="document.getElementById(\"flag_korzina\").value=\"no\";";
zagcontent2.="document.getElementById(\"center1\").innerHTML=
\"<table></table>\";";
$zagcontent2.="document.getElementById(\"centercaption1\").innerHTML=
\"<table></table>\";'></a>";
$zagcontent2=f_zag1($zagcontent2);
$objResponse->assign("centercaption1","innerHTML",$zagcontent2);
$objResponse->assign("center1","innerHTML",$content2);
//
228 II. -

$objResponse->assign("flag_korzina","value",'yes');
//
$objResponse->script("document.getElementById
('centercaption1').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

-
f_view_korzina, prgkorzina/function_view_korzina.php
( 3.45).

3.45

<?php
function f_view_korzina()
{
require_once("mybaza.php");
$text1="";
$file1="tmp1/f-".$_SESSION[session]."-".$_SESSION[user].".txt";
$fp=fopen($file1,"r");
$text1.="<form id='FormKorzina' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormKorzina\").disabled=true;
xajax.$(\"ButtonFormKorzina\").value=
\"...\";
xajax_Create_Zakaz(xajax.getFormValues(
\"FormKorzina\"));'>";
$text1.="<table width=100%>";
$text1.="<tr><td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right>-</td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0'></td>";
$text1.="</tr>";
$i=0;$summa=0;$count=0;
while($str=fgetcsv($fp,1000,";"))
{$i++;
$text1.="<tr>";
$text1.="<td class='str".($i%2+1)."' width=5%>".$i."
<input type=hidden name=korzina_id id=korzina_id
value='".$str[0]."' >
</td>";
$query1="SELECT name FROM tovars WHERE id='".$str[0]."' ";
3. 229

$text1.="<td class='str".($i%2+1)."' width=60%>


".mysql_result(mysql_query($query1),0)."</td>";
$text1.="<td class='str".($i%2+1)."' width=10%><input type=text
name=korzina_kol".$str[0]." id=korzina_kol".$str[0]."
value='".$str[1]."' size=3 maxlength=3 ".READONLYK."
onchange='var x=new Array();x[0]=".$str[0].";x[1]=this.value;
xajax_Change_Kol_Korzina(x);'>
</td>";
$text1.="<td class='str".($i%2+1)."' width=10%><input type=text
name=korzina_pay".$str[0]."
id=korzina_pay".$str[0]." value='".$str[2]."' size=3
maxlength=6 readonly
onclick='document.getElementById(
\"korzina_kol".$str[0]."\").focus();
return false;'></td>";
$text1.="<td class='str".($i%2+1)."' width=10%><input
type=text name=korzina_summa".$str[0]."
id=korzina_summa".$str[0]." value='".$str[2]*$str[1]."'
size=6 maxlength=6 readonly
onclick='document.getElementById(
\"korzina_kol".$str[0]."\").focus();
return false;' ></td>";
$text1.="<td class='str".($i%2+1)."' width=5%><a href='
javascript:void();' onclick='
xajax_Delete_From_Korzina(".$str[0].")'><img
src='img/delete.png'>
</a></td>";
$text1.="</tr>";
$summa+=$str[1]*$str[2];
$count+=$str[1];
}
$text1.="</table>";
$text1.="<br>
<div id='itogo_korzina'> - - ".$count." ,
".$summa." .</div>
<br>";
$text1.="<center><input type='submit' id='ButtonFormKorzina'
value=' ->'></center>";

$text1.="</form>";
return $text1;
}
?>
230 II. -


READONLYK my.php -
.

3.6.3.
:
;
.

3.6.3.1.
READONLYK my.php yes, -
.
onchange xajax- Change_Kol_Korzina,
prgkorzina/change_kol_korzina.php ( 3.46).

3.46

<?php
//
function Change_Kol_Korzina($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_change_kol_korzina($Id);
if($content=='yes') //
{
// " "
$content1=f_korzina_right();
//
$content2=f_view_korzina();
// javascript
//
$script2="if(document.forms.Flags.flag_korzina.value=='yes')";
$script2.="{xajax_View_Korzina();}";
$objResponse->script($script2);
// " "
$objResponse->assign("right2","innerHTML",$content1);
//
$objResponse->script("document.getElementById('right2').
scrollIntoView();");
}
else //
3. 231

$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>


f_change_kol_korzina, prgkorzina/function_
change_ kol_korzina .php ( 3.47).

3.47

<?php
function f_change_kol_korzina($Id)
{
$text1="yes";
//
$file1="tmp1/f-".$_SESSION[session]."-".$_SESSION[user].".txt";
$fp=fopen($file1,"r");
$tofile='';
while($str=fgetcsv($fp,1000,";"))
{
//
//
if($str[0]==$Id[0])
{
$tofile.=$Id[0].";".$Id[1].";".$str[2].";"."\r\n";
}
else
$tofile.=implode($str,";")."\r\n";
}
fclose($fp);
//
$fp=fopen($file1,"w");
if(!fwrite($fp,$tofile))
$text1="no";
fclose($fp);
return $text1;
}
?>

3.6.3.2.
, -
, (. . 3.23).
xajax- Delete_From_Korzina,
232 II. -

prgkorzina/delete_from_korzina.php ( 3.48). -
(. 3.24),
(. . 3.23).

. 3.24.

3.48

<?php
//
function Delete_From_Korzina($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_delete_from_korzina($Id);
if($content=='yes') //
{
//
$content1=f_korzina_right();
//
$content2=f_view_korzina();
// javascript
//
$script2="if(document.forms.Flags.flag_korzina.value=='yes')";
$script2.="{xajax_View_Korzina();}";
$objResponse->script($script2);
// " "
$objResponse->assign("right2","innerHTML",$content1);
//
3. 233

$objResponse->script("document.getElementById
('right2').scrollIntoView();");
}
else //
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

f_delete_from_
korzina, prgkorzina/function_delete_from_korzina.php (-
3.49).

3.49

<?php
//
function f_delete_from_korzina($Id)
{
$text1="yes";
//
$file1="tmp1/f-".$_SESSION[session]."-".$_SESSION[user].".txt";
$fp=fopen($file1,"r");
$tofile='';
while($str=fgetcsv($fp,1000,";"))
{
//
if($str[0]==$Id)
;
//
else
$tofile.=implode($str,";")."\r\n";
}
fclose($fp);
//
$fp=fopen($file1,"w");
fwrite($fp,$tofile);
fclose($fp);

return $text1;
}
?>
234 II. -

3.6.4.
(. . 3.24), -
xajax- Create_Zakaz, prgzakaz/create_
zakaz.php ( 3.50).

3.50

<?php
function Create_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
// ,
//
$content2=f_create_zakaz($Id);
$zagcontent2=" <a href='javascript:void();' onclick='";
$zagcontent2.="document.getElementById(\"flag_korzina\").value=
\"no\";";
$zagcontent2.="document.getElementById(\"center1\").innerHTML=\"\";";
$zagcontent2.="document.getElementById(\"centercaption1\").innerHTML=
\"\";'></a>";
//
$zagcontent2=f_zag1($zagcontent2);
$objResponse->script($script2);
$objResponse->assign("centercaption1","innerHTML",$zagcontent2);
$objResponse->assign("center1","innerHTML",$content2);
$objResponse->assign("flag_korzina","value",'no');
$objResponse->script("document.getElementById
('centercaption1').scrollIntoView();");
// ()
$content3=f_korzina_right();
$objResponse->assign("right2","innerHTML",$content3);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

,
f_create_zakaz, prgzakaz/function_create_zakaz.php. -
.
zakaz (id_user $_SESSION) ID
($id=mysql_insert_id();). fgetcsv -
, zakaz_table. ,
zakaz. .
3. 235


. prgkorzina
prgzakaz/function_create_zakaz.php 3.51.

3.51

<?php
function f_create_zakaz($Id)
{
//
require_once("mybaza.php");
$text1="";$text01="";
//
$file1="tmp1/f-".$_SESSION[session]."-".$_SESSION[user].".txt";
//
$query1="INSERT INTO zakaz SET id_user='".$_SESSION[user]."' ";
$rez1=mysql_query($query1);
if(!$rez1)
$text01.=$query1;
// id
$id=mysql_insert_id();
// zakaz_table
$fp=fopen($file1,"r");
$summa=0;
while($str=fgetcsv($fp,1000,";"))
{
$id_zakaz=$id;
$id_tovar=$str[0];
$kol=$str[1];
$pay_rub=$str[2];
$summa_rub=$str[1]*$str[2];
$summa_rub_oplata=0;
$link="0";
$count_download=0;
$query2="INSERT INTO zakaz_table SET
id_zakaz='".$id_zakaz."',id_tovar='".$id_tovar."',
pay_rub='".$pay_rub."',kol='".$kol."',
summa_rub='".$summa_rub."',id_link='".$link."',
count_download='".$count_download."' ";
$rez2=mysql_query($query2);
$summa+=$str[1]*$str[2];
$query02="SELECT name FROM tovars WHERE id='".$str[0]."' ";
$text01.=mysql_result(mysql_query($query02),0)." - ".$str[1]."<br>";
236 II. -

}
// zakaz
$id_user=$_SESSION[user];
$summa_rub=$summa;
$summa_rub_oplata=0;
$visible='yes';
$query3="UPDATE zakaz SET data='".date('Y-m-d H:i:s')."',
id_user='".$id_user."',summa_rub='".$summa_rub."',
pay='no',visible='".$visible."'
WHERE id='".$id."' ";
$rez3=mysql_query($query3);
// message_header4
f_create_message_header4(5,$id, $_SESSION[user]," ".date('Y-m-d
H:i:s')." ".$id." ".$summa_rub." . ");
fclose($fp);
//
$fp=fopen($file1,"w");
fwrite($fp,"");
fclose($fp);
//
$text1.="<center>";
$text1.="<br><br><b> ".$id."</b><br><br>";
$text1.=$text01;
$text1.="<br> : <br><b>".$summa." . </b> <br>";
$query4="SELECT usd,eur FROM rate ORDER BY data DESC LIMIT 0, 1 ";
$rez4=mysql_query($query4);
$row4=mysql_fetch_assoc($rez4);
$usd=$row4[usd];$eur=$row4[eur];
$text1.="<b>".sprintf("%8.2f",$summa/$usd)." usd </b> ";
$text1.="<br><b>".sprintf("%8.2f",$summa/$eur)." eur </b>";
$text1.="<br><br><input type=button value='' onclick='
xajax_Oplata_Zakaz(".$id.");' >";
$text1.="<br><br><input type=button value='' onclick='
document.getElementById(\"center1\").innerHTML=\"\";
document.getElementById(\"centercaption1\").innerHTML=
\"\";'>";
$text1.="</center>";
return $text1;
}
?>

, -
(. 3.25).
3. 237

. 3.25. .


(. . 3.25)
.

3.7.
, (. . 3.25). -

WM (Merchant.webmoney.ru), ONPAY(http://onpay.ru) (. 3.26).

. 3.26.

3.7.1. Webmoney
Oplata_Zakaz, prgoplata/ oplata_zakaz.php (-
3.52), .
238 II. -

3.52

<?php
// md5
function to_float($sum)
{
if (strpos($sum, "."))
{$sum=round($sum,2);}
else
{$sum=$sum.".0";}
return $sum;
}
//
function Oplata_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
// centercaption1
$objResponse->assign(
"centercaption1","innerHTML","<table></table>");
// centercaption1
$objResponse->assign("center1","innerHTML","<table></table>");
require_once("my.php");
//
require_once("mybaza.php");
$query1="SELECT * FROM zakaz WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<center>";
$text1.="<br><br> ".$row1[id]."<br>";
$text1.="<br><br> ".($row1[summa_rub]-
$row1[summa_rub_oplata])." .<br><br>";
// WebMoney
$text1.="<form action='https://merchant.webmoney.ru/lmi/payment.asp'
method='post' target='_blank'>
<input type='hidden' name='LMI_PAYMENT_AMOUNT'
value='".($row1[summa_rub]-$row1[summa_rub_oplata])."'>
<input type='hidden' name='LMI_PAYMENT_DESC' value='
".$row1[id]." '>
<input type='hidden' name='LMI_PAYEE_PURSE'
value='".LMI_PAYEE_PURSE_R."'>
<input type='hidden' name='LMI_PAYMENT_NO'
value='".$row1[id]."'>
<input type='hidden' name='LMI_SIM_MODE' value='0'>
<input type='submit' id='button_oplata_wm' value=' WM'
3. 239

onclick='this.disabled=true;this.value=\"...\";'>
</form>";
// end WebMoney
// ONPAY
$key=OP_KEY;
$code=$row1[id];
$summa=$row1[summa_rub]-$row1[summa_rub_oplata];
$sum_for_md5=to_float($summa);
// ,
//
$md5check=md5("fix;$sum_for_md5;RUR;$code;yes;$key");
$url_onpay="http://secure.onpay.ru/pay/".OP_LOGIN."?pay_mode=
fix&pay_for=".$code;
$url_onpay.="&price=".$summa."&currency=RUR&convert=
yes&md5=".$md5check;
$url_onpay.="&price=".$summa."&currency=RUR&convert=yes";
//$url_onpay.="&url_success=".OP_PATH;
$text1.="<form action='javascript:void();' onclick='
window.open(\"".$url_onpay."\",\"\",\"\");'>
input type='submit' id='button_oplata_wm' value='
ONPAY '
disabled=true onclick='this.disabled=true;this.value=
\"...\";'></form>";
// end ONPAY
$text1.="<br><br><input type=button value='' onclick='
document.getElementById(\"center5\").innerHTML=\"\";
document.getElementById(\"centercaption5\").innerHTML=\"\";
'>";
$text1.="</center>";

$zag=f_zag1(" ");
$objResponse->assign("centercaption5","innerHTML",$zag);
$objResponse->assign("center5","innerHTML",$text1);
$objResponse->script("document.getElementById('center5')
.scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

WM -
-,
. :
LMI_PAYMENT_AMOUNT ;
LMI_PAYMENT_DESC ;
240 II. -

LMI_PAYEE_PURSE ;
LMI_PAYMENT .

, - - . -
prgoplata/wm_result.php ( 3.53).
, e-mail
.

3.53

<?php
require_once("../my.php");
require_once("../mybaza.php");
require_once("function_create_message_header4.php");
// , ...
IF($_POST['LMI_PREREQUEST']==1)
{
// 1) , .
if( trim($_POST['LMI_PAYEE_PURSE'])==LMI_PAYEE_PURSE_R )
{
echo "YES";
exit;
}
else
{
echo "ERR: ";
exit;
}
}
// LMI_PREREQUEST, , //...
ELSE
{
// $secret_key.
// Secret Key, .
$secret_key=SECRET_KEY;
//
$common_string =
$_POST['LMI_PAYEE_PURSE'].$_POST['LMI_PAYMENT_AMOUNT'].$_POST['LMI_PAYMENT_NO'].
$_POST['LMI_MODE'].$_POST['LMI_SYS_INVS_NO'].$_POST['LMI_SYS_TRANS_NO'].
$_POST['LMI_SYS_TRANS_DATE'].$secret_key.$_POST['LMI_PAYER_PURSE'].$_
POST['LMI_PAYER_WM'];
// MD5
$hash = strtoupper(md5($common_string));
// ,
if($hash!=$_POST['LMI_HASH'])
3. 241

exit;
else
{
$summa_rub=$_POST['LMI_PAYMENT_AMOUNT'];
$kod=$_POST['LMI_SYS_TRANS_NO'];
$id_zakaz=$_POST['LMI_PAYMENT_NO'];
$query1="UPDATE oplata SET data='".date("Y-m-d
H:i:s")."',id_zakaz='".$id_zakaz."', kod='".$kod."',
plat_system='wm',summa_rub='".$summa_rub."' ";
$rez1=mysql_query($query1);
$query1="INSERT INTO oplata SET data='".date("Y-m-d
H:i:s")."',id_zakaz='".$id_zakaz."',
kod='".$kod."',plat_system='wm',summa_rub='".$summa_rub."' ";
$rez1=mysql_query($query1);
$query11="SELECT summa_rub_oplata,summa_rub FROM zakaz
WHERE id='".$id_zakaz."' ";
$summa_rub_oplata=mysql_result
(mysql_query($query11),0,"summa_rub_oplata");
$summa_rub_zakaz=mysql_result(mysql_query($query11),0,"summa_rub");
$summa_rub_oplata_new=$summa_rub_oplata+$summa_rub;
$query12="UPDATE zakaz SET summa_rub_oplata='".$summa_rub_oplata_new."'
WHERE id='".$id_zakaz."' ";
$rez12=mysql_query($query12);
$Id=$id_zakaz;
if($summa_rub_oplata_new>=$summa_rub_zakaz)
{
$query13="UPDATE zakaz SET pay='yes' WHERE id='".$Id."' ";
$rez13=mysql_query($query13);
//
$data=date('Y-m-d',strtotime('now+10days'));
$query2="SELECT id,id_tovar FROM zakaz_table WHERE id_zakaz=".$Id." ";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_assoc($rez2))
{
$query3="SELECT arhiv FROM tovars WHERE id='".$row2[id_tovar]."' ";
$link=mysql_result(mysql_query($query3),0);
$query4="SELECT id_user FROM zakaz WHERE id='".$Id."' ";
$id_user=mysql_result(mysql_query($query4),0);
$query5="INSERT INTO link_downloads SET id_user='".$id_user."',
file='".$link."',status='yes',data='".$data."',id_zakaz='".$Id."' ";
$rez5=mysql_query($query5);
$id_link=mysql_insert_id();
$query6="UPDATE zakaz_table SET id_link='".$id_link."'
WHERE id='".$row2[id]."' ";
$rez6=mysql_query($query6);
242 II. -

}
}
$query7="SELECT id FROM users WHERE type='9' ";
$id_user1=mysql_result(mysql_query($query7),0,"id");
$query8="SELECT id_user FROM zakaz WHERE id='".$id_zakaz."' ";
$id_user2=mysql_result(mysql_query($query8),0,"id_user");
// message_header4
f_create_message_header4(6,$id_zakaz, $id_user1," ".date('Y-m-d
H:i:s')." ".$id_zakaz."
".$summa_rub." . ");
f_create_message_header4(6,$id_zakaz, $id_user2," ".date('Y-m-d
H:i:s')." ".$id_zakaz."
".$summa_rub." . ");
}
}
?>

3.7.2. Webmoney
WebMoney.
WebMoney . -
, WM . -
Webmoney Keeper Light. (. 3.27).

. 3.27.

-
Webmoney (. 3.28).
(. 3.29) Merchant.webmoney.ru.
3. 243

. 3.28.

. 3.29. Merchant.Webmoney.ru
244 II. -

(. 3.30).
(. 3.31). , -
.
(. 3.32).
. 3.32. ,
,
.

. 3.30.

. 3.31.
3. 245

. 3.32.

. my.php

define(LMI_PAYEE_PURSE_R,'R304300549042');
define(SECRET_KEY,'12345');

3.7.3. ONPAY
"OnPay" -

. -
,
. ( -
).
1%, -
1,56% . -
.
-- (API) , -

. -
, -
.
,
. ,
, .
246 II. -

3.7.3.1.
:
" " - -
(,
, WMR, WMZ . .);
" " , (-
, WMR, WMZ, . . .). -
.
:
"" ,
. , ,
,
. , -
, . -
;
"" , ,
- -
. -
.
" " "".
" "
,
, SMS
. ,
.
"".
, //, ,
e-mail .
"" ,
. X******,
XXXX OnPay, ******
// . ""
"". ,
" " " ".
. 3.33.
CSS . CSS
. " " -
, .
.
, "" .
3. 247

SMS- ,
SMS c -
. SMS -
, WMZ. SMS-
. SMS -
0,5 10 ., 40 70% .

. 3.33.

3.7.3.2.
ONPAY . -
http://www.onpay.ru. (. 3.34)

(. 3.35).
, ,
, (. 3.36, 3.37) -
.
248 II. -

. 3.34. www.onpay.ru

. 3.35.

. 3.36.
3. 249

. 3.37.

3.7.3.3. ONPAY Merchant API


3.7.3.3.1.
OnPay ID ID
, , ,
:
" API" -
OnPay;
API URL API ;
" API",
, , -
.
OnPay API :
"check" ,
. , OnPay
. , -
, " " OnPay;
"pay" , , ,
. , -
.
:
;
OnPay "check" API , ,
( ) ;
250 II. -

(
ID , . .);
API ( , 0
) ;
API ( 0) OnPay ;
, OnPay "" -
"pay" API ,
"check", ID / , ;
API ( 0), OnPay
"" "";
API , OnPay -
API . OnPay
, API -
72 .
"" "" -
" " OnPay. ,
"" " ", API .

. 3.38.

(. 3.38) :
;
( -
) OnPay
(http://secure.onpay.ru/pay/{ });
3. 251

-
OnPay (Webmoney, Yandex
Money . .);
,
OnPay;
OnPay , OnPay
( API \ e-mail -
);
.

3.7.3.3.2.
OnPay API . 3.4.
3.4. OnPay



onpay_id 1 32 integer ( ID -
OnPay
"pay")
pay_for 1 32 - integer ID -
(- -
,
)

order_amount >0 float ,
"price"

order_ 3- string , -
currency "currency" -
-

balance_ >0 float , -
amount -

balance_ 3- ,
currency -
-

exchange_ 1 10 - float ,
rate (- -
("order_amount")
) -
-
("bal-
ance_amount")
252 II. -

3.4 ()



type check string "check"-
-
pay

,
"pay"-
-
,

comment 0 255 string , -
(-

) .

-

Payment dateTime ( , -
DateTime
"pay")
OnPay
md5 40 string MD5 -
( - .
)

3.7.3.3.3. /
OnPay
ISO8601:2000. "XML Schema Part 2: Datatypes"
dataTime:
MM-DDThh:mm:ss.fZZZZZ
:
YYYY , ;
MM , (01 . .);
DD , ( 01 31);
T "T", ;
hh hours, (24- , 00 23);
mm minutes, ( 00 59);
ss seconds, ( 00 59);
f , ;
ZZZZZ , +: : UTC.
Z UTC.
3. 253

:
2006-03-24T19:00:00+03:00 19 24 2006 , UTC + 3 .
2006-03-24T16:00:00Z , UTC.
MD5 "check"- OnPay:
type;pay_for;order_amount;order_currency;secret_key_for_api_in
MD5 "pay"- OnPay:
type;pay_for;onpay_id;order_amount;order_currency;secret_key_for_api_in

3.7.3.3.4.
order_amount order_currency ,
, -
OnPay. OnPay
.
balance_amount balance_currency -
, .
( , -
) order_amount order_currency -
. balance_amount balance_currency
().
:
http://secure.onpay.ru/pay/merchant_login?pay_mode=fix&price=100&currency=
USD&pay_for=12
100 . , -
1 . = 0,7658 . :
76,58 = 100 .
:
order_amount=100;
order_currency=USD;
balance_amount=76.58;
balance_currency=EUR.
, ,
balance_amount balance_currency , order_amount
order_currency:
order_amount=100;
order_currency=USD;
balance_amount=100;
balance_currency=USD.

3.7.3.3.5. "check"
OnPay -
3.54.
254 II. -

3.54

POST https://merchant_server/script
order_amount=100.00
order_currency=USD
pay_for=123456
type=check
md5=*

API OnPay, XML -


3.55.

3.55

<?xml version="1.0" encoding="UTF-8"?>


<result>
<code>0</code>
<pay_for>123456</pay_for>
<comment>OK</comment>
<md5>*</md5>
</result>

:
code ;
comment (-
, ). ,
OnPay;
md5 MD5 OnPay ( ,
OnPay!), c -
: type;pay_for;order_amount; order_currency;code;secret_
key_api_in.
3.56.

3.56

<?xml version="1.0" encoding="UTF-8"?>


<result>
<code>2</code>
<pay_for>123456</pay_for>
<comment>User account doesnt exist</comment>
<md5>*</md5>
</result>
3. 255

3.7.3.3.6. "pay"
OnPay -
3.57.

3.57

POST https://merchant_server/script
onpay_id=12345
pay_for=123456
order_amount=100.00
order_currency=USD
balance_amount=76.58
balance_currency=EUR
exchange_rate=0.7658
paymentDateTime=2006-03-24T19:00:00+03:00
type=pay
md5=*

API OnPay 3.58.

3.58

<?xml version="1.0" encoding="UTF-8"?>


<result>
<code>0</code>
<comment>OK</comment>
<onpay_id>12345</onpay_id>
<pay_for>123456</pay_for>
<order_id>98765</order_id>
<md5>*</md5>
</result>

:
onpay_id ID (), OnPay (
, OnPay);
order_id ID (), (-
, );
md5 MD5 OnPay ( ,
OnPay!), c -
: type;pay_for;onpay_id;order_id; order_amount;order_
currency;code;secret_key_api_in.
256 II. -

3.7.3.3.7. API
API "check"- -
"0", OnPay . -
. 3.5.
API "pay"-, OnPay
72 . -
.
OnPay , API
, 3.59.

3.59

POST https://merchant_server/script
order_amount=100.00
order_currency=USD
balance_amount=76.58
balance_currency=EUR
exchange_rate=0.7658
pay_for=123456
type=check
md5=*

API OnPay 3.60.

3.60

<?xml version="1.0" encoding="UTF-8"?>


<result>
<code>10</code>
<pay_for>123456</pay_for>
<comment>System in maintenance mode</comment>
<md5>*</md5>
</result>

3.5.


0 , " ", "pay",
" ", "check"
2 "check"
. OnPay
3 .
OnPay API
" API",
"pay". "check", OnPay
3. 257

3.5 ()


7 . MD5-
10 . OnPay -
72 , -
" API"

3.7.3.3.8.
API onpay_id, -
, API -
( , 0), . .
( ).
OnPay -
3.61.

3.61

<?xml version="1.0" encoding="UTF-8"?>


<result>
<code>0</code>
<comment>OK ( )</comment>
<onpay_id>123456</onpay_id>
<order_id>98765</order_id>
<md5>*</md5>
</result>

3.7.4.
ONPAY Merchant API
C ONPAY
Merchant API prgoplata/onpay.php ( 3.62).

3.62

<?php
//
require_once("../my.php");
//
require_once("../mybaza.php");
//
require_once("../arhivtovar/create_new_htaccess.php");
$key=OP_KEY;

$ff=fopen("1.txt","w");
258 II. -

// check OnPay ( )
if($_REQUEST['type']=='check')
{
$error=0;
$order_amount=$_REQUEST['order_amount'];
$order_currency=$_REQUEST['order_currency'];
$code=$pay_for=$_REQUEST['pay_for'];
$md5=$_REQUEST['md5'];
$sum=floatval($order_amount);
$code=intval($code); //
//
$txt=$order_amount.";".$order_currency.";".$code.";".$md5.";".$sum.";";
fwrite($ff,$error.$txt);
fclose($ff);
//
$query1="SELECT * FROM zakaz WHERE id='".$code."';";
$rez1=mysql_query($query1);
if($rez1)
{
if(mysql_num_rows($rez1))
{
$rezult=answer($_REQUEST['type'],0,$pay_for,
$order_amount,$order_currency,'OK');
// OnPay, ,
}
else
$error=1;
}
else
$error=1;
if($error==1)
$rezult=answer($_REQUEST['type'],2,$pay_for,
$order_amount,$order_currency,'Error code pay_for: '.$code);
//
}
// pay OnPay
if($_REQUEST['type']=="pay")
{
$onpay_id=$_REQUEST['onpay_id'];
$code=$pay_for=$_REQUEST['pay_for'];
$order_amount=$_REQUEST['order_amount'];
$order_currency=$_REQUEST['order_currency'];
$balance_amount=$_REQUEST['balance_amount'];
$balance_currency=$_REQUEST['balance_currency'];
$exchange_rate=$_REQUEST['exchange_rate'];
3. 259

$paymentDateTime=$_REQUEST['paymentDateTime'];
$md5=$_REQUEST['md5'];
$error='';
//
$txt=$onpay_id.";".$code.";".$order_amount.";".$order_currency.";";
$txt.=$balance_amount.";".$balance_currency.";".$exchange_rate.";";
$txt.=$paymentDateTime.";".$md5;
if (empty($onpay_id))
{
$error .=" id<br>";
}
else
{
if (!is_numeric(intval($onpay_id)))
{$error .=" <br>";}
}

if (empty($order_amount))
{$error .=" <br>";}
else
{
if (!is_numeric($order_amount))
{$error .=" <br>";}
}

if (empty($balance_amount))
{$error .=" <br>";}
else
{
if (!is_numeric(intval($balance_amount)))
{$error .=" <br>";}
}

if (empty($balance_currency))
{$error .=" <br>";}
else
{
if (strlen($balance_currency)>4)
{$error .=" <br>";}
}

if (empty($order_currency))
{$error .=" <br>";}
else
{
260 II. -

if (strlen($order_currency)>4)
{$error .=" <br>";}
}

if (empty($exchange_rate))
{$error .=" <br>";}
else
{
if (!is_numeric($exchange_rate))
{$error .=" <br>";}
}
//********** //
if (!$error)
{
//**
fwrite($ff,$txt);
fclose($ff);
//**
if(is_numeric($code))
{// pay_for -
$code=intval($code); //
$sum=floatval($order_amount);
//, ,

$query1="SELECT * FROM zakaz WHERE id='".$code."';";


$rez1=mysql_query($query1);
if(mysql_num_rows($rez1) == 1)
{
//

$md5fb=strtoupper(md5($_REQUEST['type'].";".$pay_for.";".$onpay_id.";".$order_
amount.";".$order_currency.";".$key.""));
// ( )
if ($md5fb != $md5)
{$re-
zult=answerpay($_REQUEST['type'],7,$pay_for,$order_amount,$order_currency,'Md5
signature is wrong',$onpay_id);}
else
{
//
$Id=$code;
require_once("mybaza.php");
$query1="UPDATE zakaz SET pay='yes'
WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
//
3. 261

$data=date('Y-m-d',strtotime('now+10days'));
$query2="SELECT id,id_tovar FROM zakaz_table
WHERE id_zakaz=".$Id." ";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_assoc($rez2))
{
$query3="SELECT arhiv FROM tovars WHERE
id='".$row2[id_tovar]."' ";
$link=mysql_result(mysql_query($query3),0);
$query4="SELECT id_user FROM zakaz WHERE id='".$Id."' ";
$id_user=mysql_result(mysql_query($query4),0);
$query5="INSERT INTO link_downloads SET id_user='".$id_user."',
file='".$link."',status='yes',data='".$data."',
id_zakaz='".$Id."' ";
$rez5=mysql_query($query5);
$id_link=mysql_insert_id();
$query6="UPDATE zakaz_table SET id_link='".$id_link."'
WHERE id='".$row2[id]."' ";
$rez6=mysql_query($query6);
}
// .htaccess
create_new_htaccess();
//********************
if ($rezult1)
// ,
{
$rezult=answerpay($_REQUEST['type'],0,$pay_for,
$order_amount,$order_currency,'OK',$onpay_id);
}
else
{
$rezult=answerpay($_REQUEST['type'],3,$pay_for,
$order_amount,$order_currency,'Error in mechant database queries:
operation or balance tables error',$onpay_id);
}
}
}
else
{
$rezult=answerpay($_REQUEST['type'],3,$pay_for,
$order_amount,$order_currency,'Cannot find any pay
rows acording to this parameters: wrong payment',$onpay_id);
}
}
262 II. -

else {
// pay_for -
$rezult=answerpay($_REQUEST['type'],3,$pay_for,
$order_amount,$order_currency,'Error in
parameters data',$onpay_id);
}
}
//
else
{
fwrite($ff,$error.$txt);
fclose($ff);
$rezult=answerpay($_REQUEST['type'],3,$pay_for,
$order_amount,$order_currency,'Error in parameters data',
$onpay_id);
}
}
echo $rezult;

// onpay XML pay-


function answerpay($type,$code,$pay_for,$order_amount,$order_currency,$text,
$onpay_id)
{
global $key;
$md5=strtoupper(md5("$type;$pay_for;$onpay_id;$pay_for;$order_amount;
$order_currency; $code;$key"));
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?".">\n<result>\n<code>".
$code."</code>\n <comment>".$text."</comment>\n<onpay_id>".$onpay_id.
"</onpay_id>\n <pay_for>".$pay_for."</pay_for>\n<order_id>".$pay_for.
"</order_id>\n<md5>".$md5."</md5>\n</result>";
}
// onpay XML -
function answer($type,$code,$pay_for,$order_amount,$order_currency,$text)
{
global $key;
$md5=strtoupper(md5("$type;$pay_for;$order_amount;$order_currency;$code;$key"));
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?".">\n<result>\n<code>".
$code."</code>\n<pay_for>".$pay_for."</pay_for>\n<comment>".$text."</comment>\
n<md5>".$md5."</md5>\n</result>";
}
?>

,
e-mail -
.
3. 263

3.8. ""
. 3.6.4
.
:
;
;
;
;
.

3.8.1.

(. 3.39).
xajax- View_All_Zakaz, prgzakaz/view_all_zakaz.php.
:
;
;
;
;
(/);
(-
, , , ).
. NN2 my.php
. prgzakaz/view_
all_zakaz.php 3.63.

3.63

<?php
function View_All_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_all_zakaz($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center3
$objResponse->script("document.getElementById
264 II. -

('center3').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 3.39.

f_view_all_zakaz.php,
prgzakaz/function_view_all_zakaz.php. , "" ,
.

, , ,
. visible=no zakaz.

prgzakaz/function_view_all_zakaz.php -
3.64.

3.64

<?php
// ( )
// $Id -
// id = $_SESSION[user]
function f_view_all_zakaz($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
3. 265

$text=array();
$text1="";
$query0="SELECT COUNT(id) FROM zakaz WHERE
id_user='".$_SESSION[user]."' &&
visible='yes' ORDER BY data DESC ";
$rez0=mysql_query($query0);
$count=mysql_result($rez0,0);
$pages=ceil($count/NN2);
$page=min($Id,$pages);$poz=($page-1)*NN2;
$text1.="<div class='zag_view_tovars'>";
if($count>0)
//
{
$query1="SELECT * FROM zakaz WHERE id_user='".$_SESSION[user]."' &&
visible='yes' ORDER BY data DESC LIMIT ".$poz.", ".NN2."";
$rez1=mysql_query($query1);
$text1.="<table>";
//
$text1.="<tr><td class='str0' align=right></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td></tr>";$i=0;
while($row1=mysql_fetch_assoc($rez1))
{
// ""
$i++;
//
$text1.="<tr><td class='str".($i%2+1)."'
align=right>".$row1[id]."</td>";
//
$text1.="<td class='str".($i%2+1)."'>".$row1[data]."</td>";
//
$text1.="<td class='str".($i%2+1)."'
align=right>".$row1[summa_rub]."</td>";
//
$text1.="<td class='str".($i%2+1)."'
align=right>".$row1[summa_rub_oplata]."</td>";
// /
if($row1[pay]=='yes')
$text1.="<td class='str".($i%2+1)."' align=right><font
color='blue'></font></td>";
else
$text1.="<td class='str".($i%2+1)."' align=right><font
266 II. -

color='red'></font></td>";
$text1.="<td class='str".($i%2+1)."' align=right>";
if($row1[pay]=='no')
//
//
{
$text1.="<a href='javascript:void();' onclick='
xajax_Oplata_Zakaz(".$row1[id].");'
title=''><img src='img/pay.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Edit_Zakaz(".$row1[id].");'
title=''><img src='img/edit.png'></a>";
}
//
$text1.="<a href='javascript:void();' onclick='
xajax_View_Zakaz(".$row1[id].");'
title=''><img src='img/view.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Delete_Zakaz(".$row1[id].");'
title=''><img src='img/delete.png'></a>";
$text1.="</td></tr>";
}
$text1.="</table>";
//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page-1).";
xajax_View_All_Zakaz(x);'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,5);
for($i=0;$i < count($x);$i++)
//for($i=1;$i <= $pages;$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".$x[$i].";
xajax_View_All_Zakaz(x);'> ".$x[$i]."</a>";
3. 267

}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page+1).";
xajax_View_All_Zakaz(x);'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count."
- ".$pages."<br> </center>";}
else
{$text2.="</center>";}
}
}
else
//
{
$text2="<br><center> </center><br>";
}
//
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>

3.8.2.
(.
. 3.39), :
;
;
( ).
, -
. f_form_search_zakaz,
prgzakaz/function_form_search_zakaz.php ( 3.65).

3.65

<?php
//
function f_form_search_zakaz()
{
require_once("my.php");
268 II. -

require_once("mybaza.php");
//
$text1.="<form id='FormSearchZakaz' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormSearchZakaz\").disabled=true;
xajax.$(\"ButtonFormSearchZakaz\").value=\"...\";
xajax_View_Search_Zakaz(xajax.getFormValues(
\"FormSearchZakaz\"));'>";
$text1.="<table width=100%>";
$text1.="<tr><td width=50%> </td>";
//
$text1.="<td width=50%>
<input type='text' name='number_zakaz' value='' size=5
maxlength=5>
//
<input type='hidden' id='pagesearch' name='pagesearch'
value='1'></td></tr>";
$text1.="<tr><td width=50%><b> </b></td></td></tr>";
//
$text1.="<tr><td width=50%> </td>";
$text1.="<td width=50%>
<input type='text' name='datazakaz1' id='datazakaz1'
value='".date('Y-m-d')."' size=10 maxlength=10></td></tr>";
$text1.="<tr><td width=50%> </td>";
//
$text1.="<td width=50%>
<input type='text' name='datazakaz2' id='datazakaz2'
value='".date('Y-m-d',strtotime('now +1 day'))."' size=10
maxlength=10></td></tr>";
//
$text1.="<tr><td width=50%> ( )</td>";
$text1.="<td width=50%>
<input type='text' name='name_tovar' value='' size=20
maxlength=20></td></tr>";
$text1.="</table>";
$text1.="<center><br><input type='submit' id='ButtonFormSearchZakaz'
value=' ->'></center>";
$text1.="</form>";
return $text1;
}
?>

xajax- View_Search_Zakaz,
.
prgzakaz/view_search_zakaz.php, View_Search_Zakaz,
3.66.
3. 269

3.66

<?php
function View_Search_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$zag=f_zag1(" ");
$objResponse->assign("centercaption3","innerHTML",$zag);
//
$content=f_view_search_zakaz($Id);
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
//
$objResponse->assign("ButtonFormSearchZakaz","value", " ->");
$objResponse->assign("ButtonFormSearchZakaz","disabled", false);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 3.40.

f_view_search_zakaz.php, prgzakaz/function_view_search_
zakaz.php. , ( -
), .

, ,
, .
, .


zakaz_table, tovars zakaz.
3.67.

3.67

$query0="SELECT DISTINCT(zakaz.id) FROM zakaz,zakaz_table,tovars WHERE


zakaz.visible='yes' && zakaz.id_user='".$_SESSION[user]."' ";
$name_tovar=utftowin($Id[name_tovar]);
270 II. -

if($Id[number_zakaz]>0)
{
$query0.="&& zakaz.id='".$Id[number_zakaz]."' ";
}
else
{
$query0.="&& zakaz.data >= '".$Id[datazakaz1]."' && zakaz.data
<='".$Id[datazakaz2]."' ";
if(strlen(rtrim(ltrim($name_tovar)))>0)
{
$query0.="&& LOWER(tovars.name) LIKE '%".$name_tovar."%' &&
zakaz_table.id_tovar=tovars.id &&
zakaz_table.id_zakaz=zakaz.id ";
}
}

. 3.40.

""
, , ,
. prgzakaz/function_view_search_
zakaz.php 3.68.

3.68

<?php
function f_view_search_zakaz($Id)
{
require_once("my.php");
require_once("mybaza.php");
3. 271

$text=array();
$text1="";

$query0="SELECT DISTINCT(zakaz.id) FROM zakaz,zakaz_table,tovars


WHERE zakaz.visible='yes' &&
zakaz.id_user='".$_SESSION[user]."' ";
$name_tovar=utftowin($Id[name_tovar]);
if($Id[number_zakaz]>0)
{
$query0.="&& zakaz.id='".$Id[number_zakaz]."' ";
}
else
{
$query0.="&& zakaz.data >= '".$Id[datazakaz1]."' &&
zakaz.data <='".$Id[datazakaz2]."' ";
if(strlen(rtrim(ltrim($name_tovar)))>0)
{
$query0.="&& LOWER(tovars.name) LIKE '%".$name_tovar."%' &&
zakaz_table.id_tovar=tovars.id
&& zakaz_table.id_zakaz=zakaz.id ";
}
}

$rez0=mysql_query($query0);
$count=mysql_num_rows($rez0);
$pages=ceil($count/NN2);
$page=min($Id[pagesearch],$pages);$poz=($page-1)*NN2;
$text1="<div class='zag_view_tovars'>";
if($count>0)
{
$query0.=" ORDER BY zakaz.data DESC LIMIT ".$poz.", ".NN2."";
$query1=$query0;
$rez1=mysql_query($query1);
$text1.="<table>";
$text1.="<tr><td class='str0' align=right></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td></tr>";$i=0;
while($row1=mysql_fetch_row($rez1))
{$i++;
$query2="SELECT * FROM zakaz WHERE id='".$row1[0]."' ";
$rez2=mysql_query($query2);
272 II. -

$row2=mysql_fetch_assoc($rez2);
$text1.="<tr><td class='str".($i%2+1)."'
align=right>".$row2[id]."</td>";
$text1.="<td class='str".($i%2+1)."'>".$row2[data]."</td>";
$text1.="<td class='str".($i%2+1)."'
align=right>".$row2[summa_rub]."</td>";
$text1.="<td class='str".($i%2+1)."'
align=right>".$row2[summa_rub_oplata]."</td>";
if($row2[pay]=='yes')
$text1.="<td class='str".($i%2+1)."' align=right><font
color='blue'></font></td>";
else
$text1.="<td class='str".($i%2+1)."' align=right><font
color='red'></font></td>";
$text1.="<td class='str".($i%2+1)."' align=right>";
if($row2[pay]=='no')
{
$text1.="<a href='javascript:void();' onclick='
xajax_Oplata_Zakaz(".$row2[id].");'
title=''><img src='img/pay.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Edit_Zakaz(".$row2[id].");'
title=''><img src='img/edit.png'></a>";
}
$text1.="<a href='javascript:void();' onclick='
xajax_View_Zakaz(".$row2[id].");'
title=''><img src='img/view.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Delete_Zakaz(".$row2[id].");'
title=''><img src='img/delete.png'></a>";
$text1.="</td></tr>";
}
$text1.="</table>";
//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchZakaz.pagesearch.value=".$i.";
xajax_View_Search_Zakaz(xajax.getFormValues(
\"FormSearchZakaz\"));'> <<</a>";
}
3. 273

$x=array();
$x=doarray1($page,$pages,5);
for($i=0;$i < count($x);$i++)
//for($i=1;$i <= $pages;$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchZakaz.pagesearch.value=".$x[$i].";
xajax_View_Search_Zakaz(xajax.getFormValues(
\"FormSearchZakaz\"));'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchZakaz.pagesearch.value=".$i.";
xajax_View_Search_Zakaz(xajax.getFormValues(
\"FormSearchZakaz\"));'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count."
".$pages."<br> </center>";}
else
{$text2.="</center>";}
}
}
else
{
$text2="<br><center>
</center><br>";
}
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>

3.8.3.
.
, xajax- Edit_Zakaz, -
prgzakaz/edit_zakaz.php ( 3.69). -
274 II. -

ID zakaz. table_zakaz
. (. 3.41) f_edit_zakaz,
prgzakaz/function_edit_zakaz.php ( 3.70).

. 3.41.

3.69

function Edit_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_edit_zakaz($Id);
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$content);
// center5
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
3. 275

3.70

<?php
function f_edit_zakaz($Id)
{
//
require_once("mybaza.php");
//
require_once("my.php");
$text1="";
$text1.="<form id='FormEditZakaz' action='javascript:void(null);'
onsubmit='
xajax.$(\"ButtonFormEditZakaz\").disabled=true;
xajax.$(\"ButtonFormEditZakaz\").value=\"...\";
xajax_Go_Edit_Zakaz(xajax.getFormValues(
\"FormEditZakaz\"));'>";
$text1.="<table width=100%>";
$query1="SELECT * FROM zakaz WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
//
$text1.="<br><br><b></b> ".$row1[id]."<br>";
//
if($row1[pay]=='yes')
$text1.="<br><b> </b> - <br>";
else
$text1.="<br><b> </b> - <br>";
$query2="SELECT * FROM zakaz_table WHERE id_zakaz='".$Id."' ";
$rez2=mysql_query($query2);
//
$text1.="<table>";
$text1.="<tr><td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right>-</td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0'></td>";
$text1.="</td></tr>";
$i=0;$count=0;
while($row2=mysql_fetch_assoc($rez2))
{
//
$i++;
//
$count+=$row2[kol];
276 II. -

$text1.="<tr>";
$text1.="<td class='str".($i%2+1)."' width=5%>".$i."
<input type=hidden name=table_id".$i." id=table_id".$i."
value='".$row2[id]."' >
</td>";
$query1="SELECT name FROM tovars WHERE id='".$row2[id_tovar]."' ";
$text1.="<td class='str".($i%2+1)."' width=60%>
".mysql_result(mysql_query($query1),0)."</td>";
// Change_Kol_Table onchange
// READONLYZ readonly
$text1.="<td class='str".($i%2+1)."' width=10%><input type=text
name=table_kol".$row2[id]."
id=table_kol".$row2[id]." value='".$row2[kol]."'
size=3 maxlength=3 ".READONLYZ."
onchange='var x=new Array();
x[0]=".$row2[id].";x[1]=this.value;
x[2]=document.forms.FormEditZakaz.table_pay
".$row2[id].".value;
x[3]=document.forms.FormEditZakaz.table_summa
".$row2[id].".value;
x[4]=document.forms.FormEditZakaz.itogo_count_zakaz.value;
x[5]=document.forms.FormEditZakaz.itogo_summa_zakaz.value;
xajax_Change_Kol_Table(x);'>
</td>";
//
$text1.="<td class='str".($i%2+1)."' width=10%><input type=text
name=table_pay".$row2[id]."
id=table_pay".$row2[id]." value='".$row2[pay_rub]."'
size=3 maxlength=6 readonly
onclick='document.getElementById(
\"table_kol".$row2[id]."\").focus();
return false;'></td>";
//
$text1.="<td class='str".($i%2+1)."' width=10%><input type=text
name=table_summa".$row2[id]."
id=table_summa".$row2[id]." value='".$row2[summa_rub]."'
size=6 maxlength=6 readonly
onclick='document.getElementById(
\"table_kol".$row2[id]."\").focus();
return false;' ></td>";
// ,
if(READONLYZ=='readonly')
$text1.="<td class='str".($i%2+1)."' width=5%><a href='
javascript:void();' onclick='
var x=new Array();x[0]=".$row2[id].";x[1]=\"0\";
3. 277

x[2]=document.forms.FormEditZakaz.table_pay
".$row2[id].".value;
x[3]=document.forms.FormEditZakaz.table_summa
".$row2[id].".value;
x[4]=document.forms.FormEditZakaz.itogo_count_zakaz.value;
x[5]=document.forms.FormEditZakaz.itogo_summa_zakaz.value;
xajax_Change_Kol_Table(x);'><img src='img/delete.png'>
</a></td>";
$text1.="</tr>";
}
$text1.="<tr><td></td>";
//
$text1.="<td></td>";
$text1.="<td align=right><input type=text name=itogo_count_zakaz
id=itogo_count_zakaz
value='".$count."' size=8 maxlength=8 readonly></td>";
$text1.="<td align=right></td>";
$text1.="<td align=right><input type=text name=itogo_summa_zakaz
id=itogo_summa_zakaz
value='".$row1[summa_rub]."' size=8 maxlength=8
readonly></td>";
$text1.="<td></td></tr>";
$text1.="</table>";
//
$text1.="<center><input type='submit' id='ButtonFormEditZakaz'
value=' ->'>
<br><br><input type='button' value='' onclick='
document.getElementById(\"center5\").innerHTML=\"\";
document.getElementById(\"centercaption5\").innerHTML=
\"\";'></center>";
$text1.="</form>";
return $text1;
}
?>
.
onchange xajax-
Change_Kol_Table,
. Change_Kol_Table prgzakaz/
change_kol_table.php ( 3.71).

3.71

<?php
// -
//
278 II. -

function Change_Kol_Table($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$new_summa=$Id[1]*$Id[2];
$objResponse->assign("table_summa".$Id[0],"value",$new_summa);
//
$kol_old=$Id[3]/$Id[2];
$delta_kol=$Id[1]-$kol_old;
$delta_summa=$delta_kol*$Id[2];
$new_kol=$kol_old+$delta_kol;
$objResponse->assign("table_kol".$Id[0],"value",$new_kol);
//
$new_itogo_kol=$Id[4]+$delta_kol;
$new_itogo_summa=$Id[5]+$delta_kol*$Id[2];
$objResponse->assign("itogo_count_zakaz","value",$new_itogo_kol);
$objResponse->assign("itogo_summa_zakaz","value",$new_itogo_summa);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>


READONLYZ my.php -
(. 3.42). -
READONLYZ='readonly'
,
(. 3.43).

. 3.42.
3. 279

. 3.43. READONLYZ='readonly'


id='FormEditZakaz' Go_Edit_Zakaz, -
prgzakaz/go_edit_zakaz.php, -
.
zakaz_table, zakaz. -
(. 3.44).
prgzakaz/go_edit_zakaz.php 3.72.

3.72

<?php
//
function Go_Edit_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
//
$j=(count($Id)-2)/4;
for($i=1;$i<=$j;$i++)
{
// id
$id=$Id[table_id.$i];
//
$kol=$Id[table_kol.$id];
//
$summa_rub=$Id[table_summa.$id];
280 II. -

// zakaz_table
$query1="UPDATE zakaz_table SET
kol='".$kol."',summa_rub='".$summa_rub."'
WHERE id='".$id."' ";
$rez1=mysql_query($query1);
}
//
$objResponse->alert(" !!!");
// zakaz
$query2="SELECT id_zakaz FROM zakaz_table WHERE id='".$id."' ";
$id_zakaz=mysql_result(mysql_query($query2),0);
$query3="UPDATE zakaz SET summa_rub='".$Id[itogo_summa_zakaz]."'
WHERE id='".$id_zakaz."' ";
mysql_query($query3);
//
$content=f_edit_zakaz($id_zakaz);
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$content);
// center5
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 3.44.
3. 281

3.8.4.
.
, xajax- View_Zakaz,
prgzakaz/view_zakaz.php ( 3.73). ID
zakaz. table_zakaz . -

(. 3.45).

. 3.45.

3.73

<?php
//
// $Id - id
function View_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_zakaz($Id);
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$content);
282 II. -

// center5
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

f_view_zakaz,
prgzakaz/function_view_zakaz.php ( 3.74).

3.74

<?php
//
// $Id - id
function f_view_zakaz($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text=array();
$text1="";
//
$query1="SELECT * FROM zakaz WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
//
$text1.="<br><br><b></b> ".$row1[id]."<br>";
//
if($row1[pay]=='yes')
$text1.="<b> </b> - <br>";
else
$text1.="<b> </b> - <br><br>";
//
$query2="SELECT * FROM zakaz_table WHERE id_zakaz='".$Id."' ";
$rez2=mysql_query($query2);
//
$text1.="<table>";
$text1.="<tr><td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right>-</td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0' align=right>,<br></td>";
3. 283

$text1.="<td class='str0'></td></tr>";
$i=0;
$count=0;
while($row2=mysql_fetch_assoc($rez2))
{$i++;
$text1.="<tr><td class='str".($i%2+1)."' align=right>".$i."</td>";
$query3="SELECT name FROM tovars WHERE id='".$row2[id_tovar]."' ";
$rez3=mysql_query($query3);
//
$text1.="<td class='str".($i%2+1)."'>
".mysql_result($rez3,0)."</td>";
//
$text1.="<td class='str".($i%2+1)."' align=right>
".$row2[kol]."</td>";
$count+=$row2[kol];
//
$text1.="<td class='str".($i%2+1)."' align=right>
".$row2[pay_rub]."</td>";
//
$text1.="<td class='str".($i%2+1)."' align=right>
".$row2[summa_rub]."</td>";
// , ( )
if($row2[id_link]>0)
$text1.="<td class='str".($i%2+1)."'><a href='download.php
?id=".$row2[id_link]."' target='_blank'>
<img src='img/download.png'></a></td></tr>";
else
$text1.="<td class='str".($i%2+1)."'></td>";
$text1.="</tr>";
}
$text1.="<tr><td></td>";
$text1.="<td></td>";
//
$text1.="<td align=right>".$count."</td>";
$text1.="<td align=right></td>";
//
$text1.="<td align=right>".$row1[summa_rub]."</td>";
$text1.="<td></td></tr>";
if($row1[pay]=='no')
{
$text1.="<tr><td></td>";
$text1.="<td></td>";
$text1.="<td align=right></td>";
$text1.="<td align=right></td>";
$text1.="<td align=right>".$row1[summa_rub_oplata]."</td>";
284 II. -

$text1.="<td></td></tr>";
}
$text1.="</table>";
//
if($row1[pay]=='no')
$text1.="<br><br><input type=button value='' onclick='
xajax_Oplata_Zakaz(".$row1[id].");' >";
return $text1;
}

?>

3.8.5.
.
, xajax- Delete_Zakaz, prgzakaz/
delete_zakaz.php ( 3.75). ID -
zakaz.
(. 3.46).

3.75

<?php
//
// visible=no
function Delete_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
// ""
$query1="UPDATE zakaz SET visible='no' WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
if($rez1)
{
//
$objResponse->alert(" !!!");
// 1
$content=f_view_all_zakaz(1);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center5
$objResponse->script("document.getElementById
3. 285

('center3').scrollIntoView();");
// center5 centercaption5
$objResponse->assign("centercaption5",
"innerHTML","<table></table>");
$objResponse->assign("center5","innerHTML","<table></table>");
}
else
//
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 3.46.


. zakaz -
visible.
, no.

3.8.6. .

zip, rar gz.
, -
.
arhivtovar. , .
.htaccess ( . 3.8.7).
286 II. -

-
.
Webmoney ( prgopla-
ta/wm_result.php) ONPAY ( prgoplata/onpay.php) link_downloads
: tovars
, link_downloads
ID link_downloads
zakaz_table ( id_link). 3.76.

3.76

<?php
$Id=$id_zakaz;
//
$query2="SELECT id,id_tovar FROM zakaz_table
WHERE id_zakaz=".$Id." ";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_assoc($rez2))
{
//
$query3="SELECT arhiv FROM tovars WHERE id='".$row2[id_tovar]."' ";
$link=mysql_result(mysql_query($query3),0);
// ,
$query4="SELECT id_user FROM zakaz WHERE id='".$Id."' ";
$id_user=mysql_result(mysql_query($query4),0);
// link downloads
//
// id_user
//
// id_zakaz
//
$query5="INSERT INTO link_downloads SET id_user='".$id_user."',
file='".$link."',status='yes',
data='".$data."',id_zakaz='".$Id."' ";
$rez5=mysql_query($query5);
// id
$id_link=mysql_insert_id();
//
//
$query6="UPDATE zakaz_table SET id_link='".$id_link."'
WHERE id='".$row2[id]."' ";
$rez6=mysql_query($query6);
}
}
?>
3. 287

3.8.7.
.htaccess
.htaccess ( , )
Web- Apache -
. , Web- -
, -
, .
.htaccess Web- ( -
public_html)
Web-. .htaccess ,
, , "" -
"" , public_html
. , .htaccess
, . , ,
. , .htaccess
Web- Apache.
.htaccess Web-.
, , Context -
.htaccess, .
Web- ?
:
deny from all
all "".
IP:
order allow deny
deny from all
allow from ip_
, ip_ , :
order allow deny
deny from all
allow from 192.126.12.199
IP:
order allow deny
deny from all
deny from ip_
ip_ .
3.77.

3.77

<Files "\.(inc|sql|... ...)$">


order allow,deny
288 II. -

deny from all


</Files>
.
"inc" Web-:
<Files "\.(inc)$">
order allow,deny
deny from all
</Files>

Web- Apache
, .

( 3.78).

3.78

Files config.inc.php>
order allow,deny
deny from all
</Files>

config.inc.php
, .
( 3.79).

3.79

<Files "1254513156.rar">
order deny,allow
deny from all
allow from 77.39.66.172,127.0.0.1,194.186.219.71,194.186.219.132
</Files>
<Files "1254511325.rar">
order deny,allow
deny from all
allow from 77.39.66.172,194.186.219.71
</Files>

3.8.8.

http://MYSITE/download.php?id=33, . ID
id_link link_download. download.php ( 3.80)
(. 3.47). -
(. 3.48).
, (. 3.49).
3. 289

3.80

<html>
<head>
<title> </title>
</head>
<body width=200px height=200px>
<?php
//
require_once("my.php");
//
require_once("mybaza.php");
// .htaccess

require_once("arhivtovar/create_new_htaccess.php");
// .htaccess
create_new_htaccess();
//
$query1="SELECT * FROM link_downloads WHERE id_link='".$_GET[id]."' ";
$rez1=mysql_query($query1);
$file=mysql_result($rez1,0,"file");
$id_user=mysql_result($rez1,0,"id_user");
$status=mysql_result($rez1,0,"status");
$data=mysql_result($rez1,0,"data");
if($status=='no')
// -
$text1=" - ".$data;
else
{
//
$query2="SELECT ip FROM users WHERE id='".$id_user."' ";
$rez2=mysql_query($query2);
$ip=mysql_result($rez2,0);
$ip=str_replace(";","<br>",$ip);
$text1="<center>";
$text1.=" - <a href='".SITE.$file."'>";
$text1.=SITE.$file."</a><br>";
$text1.=" ".$data."<br>";
$text1.=" ip- :<br>".$ip;
$text1.="</center>";
}
echo $text1;
?>
</body>
</html>
290 II. -

. 3.47.

. 3.48.

. 3.49.
3. 291

download.php create_new_htaccass,
arhivtovar/create_new_htaccess.php ( 3.81),
.htaccess. , -
IP- ( -
( users ip) IP).

3.81

<?php
function create_new_htaccess()
{
//
require_once("mybaza.php");
// arhivtovar
$dir=opendir("arhivtovar");
while($file1=readdir($dir))
{
if($file1 != "." && $file1 != ".." && $file1 != ".htaccess" &&
$file1 != "create_new_htaccess.php" && $file1 != "index.php")
{
// , ?
// ( link_downloads)
$query1="SELECT DISTINCT(id_user) FROM link_downloads WHERE
file='arhivtovar/".$file1."' && status='yes' ";
$rez1=mysql_query($query1);
if(mysql_num_rows($rez1)>0)
{
// , ip
$textfiles.="<Files ".$file1.">
order deny,allow
deny from all
allow from ";
while($row1=mysql_fetch_row($rez1))
{
$query2="SELECT ip FROM users WHERE id='".$row1[0]."' ";
$rez2=mysql_query($query2);
$ip=mysql_result($rez2,0);
$ip=str_replace(";",",",$ip);
$textfiles.=$ip;
}
}
}
}
closedir($dir);
$ff=fopen("arhivtovar/.htaccess","w");
292 II. -

// .htaccess
fwrite($ff,$textfiles);
fclose($ff);
//
return str_replace("\r\n","<br>",$textfiles);
}

?>

3.9.
-
, , -
. .

3.9.1.

, . JavaScript- time_go -
, time_pr=10000 ( 10 ) -
. -
time_go 3.82.

3.82

<script type="text/javascript">
function time_go()
{
var time_pr=10000;
setTimeout("time_go();",time_pr);
if(document.getElementById("flag_ajax").value=="no")
{
var str1="<img src='img/load.gif'> ";
document.getElementById("header4").innerHTML=str1;
xajax_Timer1(document.getElementById("flag_time1").value);
}
return;
}
</script>

3.82 , xajax-,
xajax- xajax_Timer1, prgmessa-
geheader4/timer1.php ( 3.83). ID
, flag_time1.
-
3. 293

: <a href="javascript:void();" onclick="xajax_


Go_Timer1(id);"> (data)</a> (. 3.50).


-
, message_header4
visible=yes. ,
visible no .

. 3.50.

3.83

<?php
//
//
function Timer1($Id)
{
session_start();
$_SESSION[user]=$_SESSION[user];
$_SESSION[session]=$_SESSION[session];
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
//
$query1="SELECT COUNT(id) FROM message_header4
WHERE id_user='".$Id."' && visible='yes' ";
$count=mysql_result(mysql_query($query1),0);
if($count>0)
{
//
//
$query2="SELECT message FROM message_header4
WHERE id_user='".$Id."' && visible='yes' ORDER BY id ASC LIMIT 1";
//
$new_messages=mysql_result(mysql_query($query2),0);
$new_messages="<img src='img/notification.gif'>"."<font
294 II. -

color=red><b>(".$count.")</b></font> ".$new_messages;
}
else
//
$new_messages=' ';
// header4
$objResponse->assign("header4","innerHTML",$new_messages);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

3.9.2.
- xajax- xajax_Go_Timer1,
prgmessageheader4/go_timer1.php ( 3.84).
type arg_id (-
, , ),
arg_id. , -
( visible=no)
.
3.84

<?php
function Go_Timer1($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
//
$query3="SELECT id_user,type,arg_id FROM message_header4
WHERE id='".$Id."' ";
$rez3=mysql_query($query3);
$id_user=mysql_result($rez3,0,"id_user");
$type=mysql_result($rez3,0,"type");
$arg_id=mysql_result($rez3,0,"arg_id");
switch($type)
{
//
case 1: $content=f_form_reg_user();
$zagcontent=f_zag1("");
$objResponse->assign("centercaption2",
"innerHTML",$zagcontent);
$objResponse->assign("center2","innerHTML",$content);
3. 295

$objResponse->script("document.getElementById
('center2').scrollIntoView();");
break;
//
case 2: $content=f_view_user_admin($arg_id);
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5",
"innerHTML",$zagcontent);
$objResponse->assign("center5","innerHTML",$content);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
break;
case 3:
break;
//
case 4: $content=f_view_message($arg_id);
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5",
"innerHTML",$zagcontent);
$objResponse->assign("center5","innerHTML",$content);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
break;
//
case 5: $content=f_view_zakaz_admin($arg_id);
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5",
"innerHTML",$zagcontent);
$objResponse->assign("center5","innerHTML",$content);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
break;
//
case 6: $content=f_view_zakaz_admin($arg_id);
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5",
"innerHTML",$zagcontent);
$objResponse->assign("center5","innerHTML",$content);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
break;
default:
break;
}
//
296 II. -

$query0="UPDATE message_header4 SET visible='no' WHERE id='".$Id."' ";


mysql_query($query0);
//
$Id=$_SESSION[user];
$query1="SELECT COUNT(id) FROM message_header4
WHERE id_user='".$Id."' && visible='yes' ";
$count=mysql_result(mysql_query($query1),0);
if($count>0)
{
$query2="SELECT message FROM message_header4 WHERE
id_user='".$Id."' && visible='yes' ORDER BY id ASC LIMIT 1";
$new_messages=mysql_result(mysql_query($query2),0);
$new_messages="<img src='img/notification.gif'>"."<font
color=red><b>(".$count.")</b></font> ".$new_messages;
}
else
$new_messages=' ';

//
$objResponse->assign("header4","innerHTML",$new_messages);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

3.9.3.
:
( , . 3.51);
( , . 3.52);
(. 3.53);
(. 3.54);
(. 3.55).

f_create_message_header4 prgmessageheader4/ func-
tion_create_message_header4.php ( 3.85).

3.85

<?php
// $arg1 - type 1-
// 2- -
// 3-
// 4-
// 5- ( )
3. 297

// 6- ( )
// $arg2 - id ,
// $arg3 - id_user ()
// $arg4 -
function f_create_message_header4($arg1,$arg2,$arg3,$arg4)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$type=$arg1;
$arg_id=$arg2;
$id_user=$arg3;
$data=date('Y-m-d H:i:s');
//
$query0="INSERT INTO message_header4 SET data='".$data."',
id_user='".$id_user."' ";
mysql_query($query0);
// id
$id=mysql_insert_id();
//
switch($arg1)
{
//
case 1: $message='<a href="javascript:void();" onclick="
xajax_Go_Timer1('.$id.');">'.$arg4.'</a>';
break;
case 2: $query01="SELECT id FROM users WHERE type='9' ";
$id_user=mysql_result(mysql_query($query01),0);
$message='<a href="javascript:void();" onclick="
xajax_Go_Timer1('.$id.');">'.$arg4.'</a>';
break;
case 3:
break;
case 4: $message='<a href="javascript:void();" onclick="
xajax_Go_Timer1('.$id.');">'.$arg4.'</a>';
break;
case 5: $query01="SELECT id FROM users WHERE type='9' ";
$id_user=mysql_result(mysql_query($query01),0);
$message='<a href="javascript:void();" onclick="
xajax_Go_Timer1('.$id.');">'.$arg4.'</a>';
break;
case 6: $message='<a href="javascript:void();" onclick="
xajax_Go_Timer1('.$id.');">'.$arg4.'</a>';
break;
298 II. -

}
//
$query1="UPDATE message_header4 SET id_user='".$id_user."',
type='".$type."',arg_id='".$arg_id."',message='".$message."',
visible='yes' WHERE id='".$id."' ";
mysql_query($query1);
return ;
}
?>

. 3.51. ( )

. 3.52. ( )

. 3.53. ( )

. 3.54. ( )

. 3.55. ( )
3. 299

3.10. ( )

. :
;
;
;
.

3.10.1.
, -
(. 3.56) /.
xajax- View_All_Messages_In,
prgmessage/view_all_messages_in.php ( 3.86).
xajax- View_All_Messages_Out,
prgmessage/view_all_messages_out.php ( 3.87). -
:
;
;
;
.

3.86

<?php
//
// $Id -
function View_All_Messages_In($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_all_messages_in($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse();
}
?>
300 II. -

3.87

<?php
//
// $Id -
function View_All_Messages_Out($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_all_messages_out($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 3.56. ()


f_view_all_messages_in f_view_all_messages_out
prgmessage/function_view_all_messages_in.php ( 3.88) prgmessage/function_
view_all_ messages_out.php ( 3.89) . -
3. 301

, NN3
my.php.

3.88

<?php
//
// $Id -
// id = $_SESSION[user]
function f_view_all_messages_in($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text=array();
$text1="";
//
$query0="SELECT COUNT(id) FROM messages WHERE
id_to='".$_SESSION[user]."' &&
visible_to='yes' ORDER BY data DESC ";
$rez0=mysql_query($query0);
$count=mysql_result($rez0,0);
$pages=ceil($count/NN3);
$page=min($Id,$pages);$poz=($page-1)*NN3;
//
$text1.="<table><tr><td align=center><b></b>
</td><td align=center>
<a href='javascript:void();' onclick='
xajax_View_All_Messages_Out(1);'>
</a></td></tr></table>";
$text1.="<div class='zag_view_messages'>";
if($count>0) //
{
$query1="SELECT * FROM messages WHERE id_to='".$_SESSION[user]."'
&& visible_to='yes' ORDER BY data DESC
LIMIT ".$poz.", ".NN3."";
$rez1=mysql_query($query1);
//
$text1.="<table>";
$text1.="<tr><td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td></tr>";
302 II. -

$i=0; //
while($row1=mysql_fetch_assoc($rez1))
{
$i++;
if($row1[view_to]=='no')
//
$text1.="<tr><td class='str".($i%2+1)."'><img
src='img/new_message.gif'></td>";
else
$text1.="<tr><td class='str".($i%2+1)."' width=5%></td>";
//
$text1.="<td class='str".($i%2+1)."'>".$row1[data]."</td>";
$query2="SELECT login FROM users WHERE id='".$row1[id_from]."' ";
$rez2=mysql_query($query2);
$login=mysql_result($rez2,0);
$login=(strlen($login)<13)?($login):(substr($login,0,12)."...");
$text1.="<td class='str".($i%2+1)."'>".$login."</td>";
//
$text1.="<td class='str".($i%2+1)."'>".$row1[theme]."</td>";
// -
$text1.="<td class='str".($i%2+1)."'><a href='javascript:void();'
onclick='xajax_View_Message(".$row1[id].");'
title=''><img src='img/view.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Delete_Message_In(".$row1[id].");'
title=''><img src='img/delete.png'></a>";
$text1.="</td></tr>";
}
$text1.="</table>";
//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page-1).";
xajax_View_All_Messages_In(x);'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,5);
for($i=0;$i < count($x);$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
3. 303

else
{
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".$x[$i].";
xajax_View_All_Messages_In(x);'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page+1).";
xajax_View_All_Messages_In(x);'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count." - ".$pages."
<br> </center>";}
else
{$text2.="</center>";}
}
}
else
{
$text1.="<center><br> <br></center>";
}
//
if($_SESSION[type]>7)
$text1.="<center><br><br><a href='javascript:void();' onclick='
xajax_Form_New_Message_Admin(0);'>
</a></center>";
else
$text1.="<center><br><br><a href='javascript:void();' onclick='
xajax_Form_New_Message();'>
</a></center>";
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>

3.89

<?php
// ( )
// $Id -
// id = $_SESSION[user]
304 II. -

function f_view_all_messages_out($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text=array();
$text1="";
//
$query0="SELECT COUNT(id) FROM messages WHERE
id_from='".$_SESSION[user]."' &&
visible_from='yes' ORDER BY data DESC ";
$rez0=mysql_query($query0);
$count=mysql_result($rez0,0);
$pages=ceil($count/NN3);
$page=min($Id,$pages);$poz=($page-1)*NN3;
//
$text1.="<table><tr><td align=center><a href='javascript:void()'
onclick='xajax_View_All_Messages_In(1);'></a></td>
<td align=center><b></b></td></tr></table>";
$text1.="<div class='zag_view_messages'>";
if($count>0)
{
//
$query1="SELECT * FROM messages WHERE id_from='".$_SESSION[user]."'
&& visible_from='yes' ORDER BY data DESC
LIMIT ".$poz.", ".NN3."";
$rez1=mysql_query($query1);
//
$text1.="<table>";
$text1.="<tr><td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td></tr>";
$i=0; //
while($row1=mysql_fetch_assoc($rez1))
{$i++;
if($row1[view_out]=='no')
//
$text1.="<tr><td class='str".($i%2+1)."'><img
src='img/noview_message.gif'></td>";
else
$text1.="<tr><td class='str".($i%2+1)."' width=5%></td>";
//
3. 305

$text1.="<td class='str".($i%2+1)."'>".$row1[data]."</td>";
$query2="SELECT login FROM users WHERE id='".$row1[id_to]."' ";
$rez2=mysql_query($query2);
$login=mysql_result($rez2,0);
$login=(strlen($login)<13)?($login):(substr($login,0,12)."...");
$text1.="<td class='str".($i%2+1)."'>".$login."</td>";
//
$text1.="<td class='str".($i%2+1)."'>".$row1[theme]."</td>";
// -
$text1.="<td class='str".($i%2+1)."'><a href='javascript:void();'
onclick='xajax_View_Message(".$row1[id].");'
title=''><img src='img/view.gif'></a>";
$text1.="<a href='javascript:void();'
onclick='xajax_Delete_Message_Out(".$row1[id].");'
title=''><img src='img/delete.png'></a>";
$text1.="</td></tr>";
}
$text1.="</table>";
//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page-1).";
xajax_View_All_Messages_Out(x);'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,5);
for($i=0;$i < count($x);$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".$x[$i].";
xajax_View_All_Messages_Out(x);'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page+1).";
306 II. -

xajax_View_All_Messages_Out(x);'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count." - ".$pages."<br>
</center>";}
else
{$text2.="</center>";}
}
}
else
{
$text1.="<center><br> <br></center>";
}
$text1.="<center><br><br><a href='javascript:void();' onclick='
xajax_Form_New_Message();'>
</a></center>";
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>

3.10.2.
-
(. 3.57). xajax- View_Message -
, ID . View_Message -
prgmessage/view_message.php ( 3.90).

3.90

<?php
//
// $Id - id message
function View_Message($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_message($Id);
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$content);
3. 307

// center5
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 3.57.

f_view_message prgmes-
sage/ function_view_message.php ( 3.91).

3.91

<?php
//
// $Id - id message
function f_view_message($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text=array();
$text1="";
308 II. -

//
$query1="SELECT * FROM messages WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
if($_SESSION[user]==$row1[id_to]) //
{
//
$query3="UPDATE messages SET view_to='yes' WHERE id='".$Id."' ";
mysql_query($query3);
// header4
$query2="SELECT login FROM users WHERE id='".$row1[id_from]."' ";
$rez2=mysql_query($query2);
$text1.="<br><br><b> ".mysql_result($rez2,0)."</b><br>";
}
else //
{
$query2="SELECT login FROM users WHERE id='".$row1[id_to]."' ";
$rez2=mysql_query($query2);
$text1.="<br><br><b> ".mysql_result($rez2,0)."</b><br>";
}
$text1.="<br><b> : </b> ".$row1[theme]."<br>";
$text1.="<br><b> : </b> ".$row1[message]."<br>";
//
if($_SESSION[user]==$row1[id_to])
{
if($_SESSION[type]=='1' || $_SESSION[type]=='2' )
$text1.="<center><br><br><a href='javascript:void();' onclick='
xajax_Form_New_Message();'>
</a></center>";
else
$text1.="<center><br><br><a href='javascript:void();' onclick='
xajax_Form_New_Message_Admin(".$row1[id_from].");'>
</a></center>";
}
return $text1;
}
?>

3.10.3.

(. 3.58). xajax- Delete_Message_In ( -
) Delete_Message_Out ( ) , ID
. Delete_Message_In prgmessage/
delete_message_in.php ( 3.92), Delete_Message_Out
prgmessage/delete_message_out.php ( 3.93).
3. 309

, messages
visible_to ( ) visible_from ( ) no, -
, ( ) .

. 3.58.

3.92

<?php
//
// $Id - id message
// visible_to=no
function Delete_Message_In($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
// ( visible_to=no)
$query1="UPDATE messages SET visible_to='no' WHERE id='".$Id."' ";
if(!mysql_query($query1))
$objResponse->alert(" !!!");
else
$objResponse->alert(" ");
//
$content=f_view_all_messages_in($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
310 II. -

// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

3.93

<?php
//
// $Id - id message
// visible_out=no
function Delete_Message_Out($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
// ( visible_out=no)
$query1="UPDATE messages SET visible_out='no' WHERE id='".$Id."' ";
if(!mysql_query($query1))
$objResponse->alert(" !!!");
else
$objResponse->alert(" ");
//
$content=f_view_all_messages_out($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

3.10.4.
-
( xajax- Form_New_Message) (. 3.59),
prgmessage/form_new_message.php ( 3.94).
3. 311

3.94

<?php
//
function Form_New_Message()
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
$text1="";
$text1.="<form id='FormNewMessage' action='javascript:void(null);'
onsubmit='
xajax.$(\"ButtonFormNewMessage\").disabled=true;
xajax.$(\"ButtonFormNewMessage\").value=
\"...\";
xajax_Add_New_Message(xajax.getFormValues(
\"FormNewMessage\"));'>";
$text1.="<table width=100%>";
$text1.="<caption> </caption>";
$text1.="<tr><td width=30%></td>
<td width=70%><input type='text' name='theme'
size='30' maxlength='30' value='' ></td></tr>";
$text1.="<tr><td width=30%> ( 256 )</td>
<td width=70%><textarea name='message'
cols='30' rows='5' value='' >
</textarea></td></tr>";
$text1.="<tr><td></td>
<td>
<input type='submit' id='ButtonFormNewMessage'
value=' ->' >
</td>
<td></td></tr>";
$text1.="</table>";
$text1.="</form>";
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$text1);
// center3
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
312 II. -

. 3.59.

. 3.60.

. 3.61.
3. 313

,
Add_New_Message c id=FormNewMessage.
(. 3.60),
(. 3.61). Add_New_Message prgmes-
sage/add_new_message.php ( 3.95).

3.95

<?php
//
// $Id - id message
function Add_New_Message($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
$error="";
//
if(strlen(trim($Id[theme]))==0)
$error.=" !";
if(strlen(trim($Id[message]))==0)
$error.=" !";
if($error=="") //
{
$data=date('Y-m-d H:i:s');
$id_from=$_SESSION[user];
$query1="SELECT id FROM users WHERE type='9' ";
$rez1=mysql_query($query1);
$id_to=mysql_result($rez1,0);
$theme=utftowin($Id[theme]);
$message=utftowin($Id[message]);
$message=str_replace("*","",$message);
$message=str_replace("*","",$message);
$query2="INSERT INTO messages SET data='".$data."',
id_from='".$id_from."',id_to='".$id_to."',
theme='".$theme."',message='".$message."' ";
if(!mysql_query($query2))
$objResponse->alert(" !");
else
{
//
$query3="SELECT login FROM users WHERE id='".$id_from."' ";
$rez3=mysql_query($query3);
f_create_message_header4(4,mysql_insert_id(),$id_to, "
314 II. -

".mysql_result($rez3,0)." (".$data.")");
//
$objResponse->assign("centercaption5","innerHTML","");
$objResponse->assign("center5","innerHTML","");
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
$objResponse->alert(" !");
}
}
else //
{
$objResponse->alert($error);
$objResponse->assign("ButtonFormNewMessage","value", " ->");
//
$objResponse->assign("ButtonFormNewMessage","disabled", false);
}
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
4



-
:
:
;
;
;
;
:
;
;
;
;
:
;
;
;
;
:
;
;
;
;
.

4.1.
-
. users type 9 (
). -
(. 4.1)
316 II. -

. ,
mainmenu.

. 4.1.

4.2.
, , -
, -
, :
(. 4.2),
( ) (. 4.3).

. 4.2.
4. 317

. 4.3.

4.2.1.
(. . 4.2)
prgtovars_admin/add_new_tovar.php ( 4.1) xajax-
Add_New_Tovar.

4.1

<?php
//
function Add_New_Tovar()
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$zag=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zag);
//
$content=f_add_new_tovar();
//
$objResponse->assign("center5","innerHTML",$content);
// center5
$objResponse->script("document.getElementById
318 II. -

('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

-
f_add_new_tovar, prgtovars_admin/function_add_new_
tovar.php ( 4.2).

4.2

<?php
//
function f_add_new_tovar()
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text1="<center>";
$text1.="<form id='FormRegTovar' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormRegTovar\").disabled=true;
xajax.$(\"ButtonFormRegTovar\").value=\"...\";
xajax_Go_Add_New_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'>";
$text1.="<table width=100%>";
$text1.="<caption> </caption>";
//
$text1.="<input type='text' name='id_tovar' id='id_tovar' value='0' ";
//
$query1="SELECT id FROM kategory WHERE id_parent='0'";
$rez1=mysql_query($query1);
$row1=mysql_fetch_row($rez1);
$rezfun=f_regtovar_open_kategory($row1[0]);
$text1.="<tr><td width=30% valign=top></td>
<td width=50%><center>
<input type='text' name='tovar_kategory' id='tovar_kategory'
value='' onchange='xajax_Control_Reg_Tovar
(xajax.getFormValues(\"FormRegTovar\"));'>";
$text1.="<div class='menu' style='margin-left:0' id=regtovar_kategory1>
".$rezfun."</div>";
$text1.="</td>
<td width=20%>
<div id='reg_tovar_kategory'><font color='red'>no</font>
4. 319

</div>
</td></tr>";
//
$text1.="<tr><td width=30% valign=top></td>
<td width=50%><center><img id=new_tovar_img
src='resize_100.php?pic=imgtovar/nofoto.gif'>
<br><input type='text' name=name_tovar_img id=name_tovar_img
value='imgtovar/nofoto.gif'>
</center>
<div id='iframe_img'><iframe src='upload_img.php?id=1'
frameborder='0'></iframe></div>
</td>
<td width=20%>
<div id='reg_tovar_img'><font color='blue'>ok</font>
</div>
</td></tr>";
//
$text1.="<tr><td width=30%></td>
<td width=50%><input type='text' name='name' id='name'
size='30' maxlength='50' value='' onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'></td>
<td width=20%>
<div id='reg_tovar_name'><font color='red'>no</font></div>
</td></tr>";
//
$text1.="<tr><td width=30%> </td>
<td width=50%><textarea name='info' id='info'
cols='30' rows='5' value='' onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'></textarea>
</td>
<td width=20%>
<div id='reg_tovar_info'><font color='red'>no</font></div>
</td></tr>";
//
$text1.="<tr><td width=30%> </td>
<td width=50%><textarea name='fullinfo' id='fullinfo'
cols='30' rows='5' value='' onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'></textarea>
</td>
<td width=20%>
<div id='reg_tovar_fullinfo'><font
color='red'>no</font></div>
320 II. -

</td></tr>";
//
$text1.="<tr><td width=30%>, .</td>
<td width=50%><input type='text' name='pay_rub' id='pay_rub'
size='10' maxlength='10' value='' onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'></td>
<td width=20%>
<div id='reg_tovar_pay_rub'><font
color='red'>no</font></div>
</td></tr>";
//
$text1.="<tr><td width=30%> (), .</td>
<td width=50%><input type='text' name='new_pay_rub'
id='new_pay_rub' size='10' maxlength='10' value='' onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'></td>
<td width=20%>
<div id='reg_tovar_new_pay_rub'><font
color='red'>no</font></div>
</td></tr>";
// -
$text1.="<tr><td width=30% valign=top></td>
<td width=50%><center><img id=new_arhiv_img
src='imgtovar/null.gif'>
<br><input type='text' name=name_tovar_arhiv
id=name_tovar_arhiv value=''
onchange='xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'>
<div id='iframe_arhiv'><iframe src='upload_arhiv.php?id=1'
frameborder='0'></iframe></div>
</center>
</td>
<td width=20%>
<div id='reg_tovar_arhiv'><font color='red'>no</font>

</div>
</td></tr>";
// submit
$text1.="<tr><td></td>
<td>
<input type='submit' id='ButtonFormRegTovar'
value=' ->' disabled=true>
</td>
<td></td></tr>";
4. 321

$text1.="</table>";
$text1.="</form>";
return $text1;
}
?>

. 4.4 4.5.

. 4.4.

. 4.5. ()
322 II. -

-
. . -
. -
( ) xajax-
Control_Reg_Tovar, prgtovars_admin/control_reg_
tovar.php ( 4.3) onchage.
FormRegTovar.

4.3

<?php
//
//
function Control_Reg_Tovar($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
$count=0; //
//
require_once("mybaza.php");
$id_kategory=explode(";",trim(utftowin($Id[tovar_kategory])));
$query1="SELECT id FROM kategory WHERE id='".$id_kategory[0]."' ";
$rez1=mysql_query($query1);
if(mysql_num_rows($rez1)>0)
{
$query2="SELECT COUNT(id) FROM kategory WHERE
id_parent='".$id_kategory[0]."' ";
$rez2=mysql_query($query2);
}
//
if(trim(utftowin($Id[tovar_kategory]))=='')
$objResponse->assign("reg_tovar_kategory","innerHTML","<font
color='red'>no</font>");
elseif(mysql_num_rows($rez1)==0)
$objResponse->assign("reg_tovar_kategory","innerHTML","<font
color='red'> ID=".$id_kategory[0]."
</font>");
elseif(mysql_result($rez2,0)>0)
$objResponse->assign("reg_tovar_kategory","innerHTML","<font
color='red'> ,
</font>");
else
{
$objResponse->assign("reg_tovar_kategory","innerHTML","<font
color='blue'></font>");
4. 323

$count++;
}
//
if(strlen(trim(utftowin($Id[name])))>10)
{
$objResponse->assign("reg_tovar_name","innerHTML","<font
color='blue'></font>");
$count++;
}
else
{
$objResponse->assign("reg_tovar_name","innerHTML","<font
color='red'>no</font>");
}
//
if(strlen(trim(utftowin($Id[info])))>20)
{
$objResponse->assign("reg_tovar_info","innerHTML","<font
color='blue'></font>");
$count++;
}
else
{
$objResponse->assign("reg_tovar_info","innerHTML","<font
color='red'>no</font>");
}
//
if(strlen(trim(utftowin($Id[fullinfo])))>20)
{
$objResponse->assign("reg_tovar_fullinfo","innerHTML","<font
color='blue'></font>");
$count++;
}
else
{
$objResponse->assign("reg_tovar_fullinfo","innerHTML","<font
color='red'>no</font>");
}
//
if(ereg("^([0-9]{1})([0-9\.]{1,9})$",$Id[pay_rub]) &&
substr_count($Id[pay_rub],".")<2)
{
$objResponse->assign("reg_tovar_pay_rub","innerHTML","<font
color='blue'></font>");
$count++;
324 II. -

}
else
$objResponse->assign("reg_tovar_pay_rub","innerHTML","<font
color='red'>ERR</font>");
//
if(ereg("^([0-9]{1})([0-9\.]{1,9})$",$Id[new_pay_rub]) &&
substr_count($Id[new_pay_rub],".")<2)
{
$objResponse->assign("reg_tovar_new_pay_rub","innerHTML","<font
color='blue'></font>");
$count++;
}
else
$objResponse->assign("reg_tovar_new_pay_rub","innerHTML","<font
color='red'>ERR</font>");
//
if(file_exists($Id[name_tovar_arhiv]))
{
$objResponse->assign("reg_tovar_arhiv","innerHTML","<font
color='blue'></font>");
$count++;
}
else
$objResponse->assign("reg_tovar_arhiv","innerHTML","<font
color='red'>ERR</font>");
// ,
if($count==7)
$objResponse->assign("ButtonFormRegTovar","disabled",false);
else
$objResponse->assign("ButtonFormRegTovar","disabled",true);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse();
}
?>

.
.
, :
<div id='iframe_img'><iframe src='upload_img.php?id=1'
frameborder='0'></iframe></div>
<div id='iframe_arhiv'><iframe src='upload_arhiv.php?id=1'
frameborder='0'></iframe></div>
upload_img
, -
(. 4.6). upload_img.php
4. 325

upload_arhiv.php, 4.4 4.5 -


.

4.4

<?php
if ($_FILES["image"]["error"] == 0)
{
;
$ftmp = $_FILES['image']['tmp_name'];
$oname = $_FILES['image']['name'];
$fname = "imgtovar/".time()."";
$pictype="";
switch(strtolower($_FILES['image']['type']))
{
case "image/jpeg" : $pictype=".jpg"; break;
case "image/pjpeg": $pictype=".jpg"; break;
case "image/gif" : $pictype=".gif"; break;
case "image/png" : $pictype=".png"; break;
case "image/x-png": $pictype=".png"; break;
default : $pictype=""; break;
}
if($pictype=="")
{;?>
<?
if($_GET[id]!=1){ ?>
<html><head><script>
var par = window.parent.document;
par.forms.FormRegTovar.elements.name_tovar_img.value=
"imgtovar/nofoto.gif";
var new_tovar_img = par.getElementById('new_tovar_img');
<? if($_GET[id]==2) {?>
new_tovar_img.src = 'img/zagruzka.gif';
<?}
else {?>
new_tovar_img.src = 'resize_100.php?pic=imgtovar/nofoto.gif';
<? } ?>
par.getElementById('reg_tovar_img').innerHTML="<font color='red'>
</font>";
<? }
else { ;?>
<html><head><script>
var par = window.parent.document;
var new_tovar_img = par.getElementById('new_tovar_img');
var old_img = par.getElementById('name_tovar_img').value;
326 II. -

new_tovar_img.src = 'resize_100.php?pic='+old_img;
;
<? }
}
else
{;
$fname = "imgtovar/".time().$pictype;
move_uploaded_file($ftmp, $fname);
chmod($fname,0777);
?>
<html><head><script>
var par = window.parent.document;
var new_tovar_img = par.getElementById('new_tovar_img');
new_tovar_img.src = 'resize_100.php?pic=<? echo $fname; ?>';
par.forms.FormRegTovar.elements.name_tovar_img.value="<? echo $fname; ?>";
par.getElementById('reg_tovar_img').innerHTML="<font color='blue'>
</font>";
<?php
}

}
else
{;?><html><head>
<script language="javascript">
<? } ?>
function upload_img()
{
var par = window.parent.document;
var new_tovar_img = par.getElementById('new_tovar_img');
new_tovar_img.src = 'img/zagruzka.gif';
document.iform.submit();
}
</script>
<style>
iframe {
border-width: 0px;
height: avto;
width: 200px;
}
iframe.hidden {
visibility: hidden;
width:0px;
height:0px;
}
#file {
4. 327

width: 150px;
}
</style>
</head><body><center>
<form name="iform" action="" method="post" enctype="multipart/form-data">
<br> *.jpg,*.png,*.gif<br>
<input id="file" type="file" name="image" onchange="upload_img()" />
</form>
</center>
</body>
</html>

. 4.6.

4.5

<?php
if ($_FILES["arhiv"]["error"] == 0)
{
$ftmp = $_FILES['arhiv']['tmp_name'];
$oname = $_FILES['arhiv']['name'];
$fname = "arhivtovar/".time()."";
$type="";
if(strtolower($_FILES['arhiv']['type'])=="application/x-gzip-
compressed")
$type=".gz";
elseif(strtolower($_FILES['arhiv']['type'])=="application/x-gzip")
$type=".gz";
elseif(strtolower($_FILES['arhiv']['type'])=="application/x-zip-
compressed")
$type=".zip";
elseif(strtolower($_FILES['arhiv']['type'])=="application/x-rar-
compressed")
328 II. -

$type=".rar";
elseif(strtolower($_FILES['arhiv']['type'])=="application/octet-stream"
&& substr($_FILES['arhiv']['name'],
strrpos($_FILES['arhiv']['name'],"."),
strlen($_FILES['arhiv']['name'])-1)=='.rar')
$type=".rar";
else
$type="";

if($type!="")
{$fname = "arhivtovar/".time().$type;
move_uploaded_file($ftmp, $fname);
chmod($fname,0777);
?>
<html><head><script>
var par = window.parent.document;
var new_arhiv_img = par.getElementById('new_arhiv_img');
new_arhiv_img.src = 'img/null.gif';
par.forms.FormRegTovar.elements.name_tovar_arhiv.value="
<? echo $fname; ?>";
par.getElementById('reg_tovar_arhiv').innerHTML="<font
color='blue'>ok</font>";
<?}
else {
if($_GET[id] != 1 ){?>
<html><head><script>
var par = window.parent.document;
var new_arhiv_img = par.getElementById('new_arhiv_img');
new_arhiv_img.src = 'img/null.gif';
par.forms.FormRegTovar.elements.name_tovar_arhiv.value="";
par.getElementById('reg_tovar_arhiv').innerHTML="<font color='red'>
</font>";
<?php }
else { ?>
<html><head><script>
var par = window.parent.document;
var new_arhiv_img = par.getElementById('new_arhiv_img');
new_arhiv_img.src = 'img/null.gif';
<?php }
}
}
else
{?><html><head>
<script language="javascript">
<? } ?>
4. 329

function upload_arhiv()
{
var par = window.parent.document;
var new_arhiv_img = par.getElementById('new_arhiv_img');
new_arhiv_img.src = 'img/zagruzka.gif';
document.iform.submit();
</script>
<style>
iframe {
border-width: 0px;
height: avto;
width: 200px;
}
iframe.hidden {
visibility: hidden;
width:0px;
height:0px;
}
#file {
width: 150px;
}
</style>
<head><body><center>
<form name="iform" action="" method="post" enctype="multipart/form-data">
<br> zip,rar,gz<br>
<input id="file" type="file" name="arhiv" onchange="upload_arhiv()" />
</form>
</center>
</body>
</html>

, -
. prgtovars_admin/go_add_new_tovar.php (-
4.6) xajax- Go_Add_New_Tovar,
FormRegTovar.
(. 4.7).
.

4.6

<?php
//
//
function Go_Add_New_Tovar($Id)
{
$objResponse = new xajaxResponse();
330 II. -

$objResponse->assign("flag_ajax","value",'yes');
require_once("my.php");
require_once("mybaza.php");

$id_tovar=$Id[id_tovar];
$arr_id_kategory=explode(";",$Id[tovar_kategory]);
$id_kategory=$arr_id_kategory[0];
$name=utftowin($Id[name]);
$info=utftowin($Id[info]);
$fullinfo=utftowin($Id[fullinfo]);
$pay_rub=$Id[pay_rub];
$new_pay_rub=$Id[new_pay_rub];
$img=$Id[name_tovar_img];
$arhiv=$Id[name_tovar_arhiv];
$data=date('Y-m-d H:i:s');
//
if($id_tovar>0)
{
$query0="SELECT visible FROM tovars WHERE id='".$id_tovar."' ";
$visible=mysql_result(mysql_query($query0),0);
$query1="UPDATE tovars SET
id_kategory='".$id_kategory."',name='".$name."',
info='".$info."',fullinfo='".$fullinfo."',
pay_rub='".$pay_rub."',new_pay_rub='".$new_pay_rub."',
img='".$img."',arhiv='".$arhiv."',
data_update='".$data."',visible='no'
WHERE id='".$id_tovar."' ";
$rez1=mysql_query($query1);
}
//
else
{
$visible='no';
$query1="INSERT INTO tovars SET
id_kategory='".$id_kategory."',name='".$name."',
info='".$info."',fullinfo='".$fullinfo."',
pay_rub='".$pay_rub."',new_pay_rub='".$new_pay_rub."',
img='".$img."',arhiv='".$arhiv."',
data='".$data."',visible='no'
";
$rez1=mysql_query($query1);
$id_tovar=mysql_insert_id();
}
if(!$rez1)
$text1="<center> mysql ( ) </center>".$query1;
else
4. 331

$text1="<center><br>! <br><br>
<a href='javascript:void()' onclick='
xajax_View_Tovar(".$id_tovar.");'>
</a></center>";
if($Id[id_tovar]>0 && $visible=='yes')
{
$id_parent=$id_kategory;
while($id_parent>0)
{
$query3="SELECT id,id_parent,nn FROM kategory WHERE
id='".$id_parent."' ";
$rez3=mysql_query($query3);
$id_parent=mysql_result($rez3,0,"id_parent");
$id_kategory=mysql_result($rez3,0,"id");
$nn=mysql_result($rez3,0,"nn");
$new_nn=$nn-1;
$query4="UPDATE kategory SET nn='".$new_nn."' WHERE
id='".$id_kategory."' ";
mysql_query($query4);
}
//
// ..
$content=f_open_kategory(1);
$objResponse->assign("kategory1","innerHTML",$content);
}
//
$objResponse->assign("center5","innerHTML",$text1);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>


Go_Add_New_Tovar
, .

(. . 4.7) -
.

. 4.7.
332 II. -

4.2.2.
(. . 4.2) xajax-
Edit_Tovar, prgtovars_admin/edit_tovar.php ( 4.7).

4.7

<?php
//
function Edit_Tovar($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$zag=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zag);
// -
$content=f_edit_tovar($Id);
//
$objResponse->assign("center5","innerHTML",$content);
// center5
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

-
f_edit_tovar, prgtovars_admin/function_edit_tovar.php
( 4.8). . 4.8.
4.8

<?php
//
// $Id id
function f_edit_tovar($Id)
{
require_once("mybaza.php");
require_once("my.php");
//
$query0="SELECT * FROM tovars WHERE id='".$Id."' ";
$rez0=mysql_query($query0);
$row0=mysql_fetch_assoc($rez0);
$text1="<center>";
4. 333

$text1.="<form id='FormRegTovar' action='javascript:void(null);'


onsubmit='
xajax.$(\"ButtonFormRegTovar\").disabled=true;
xajax.$(\"ButtonFormRegTovar\").value=\"...\";
xajax_Go_Add_New_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'>";
$text1.="<table width=100%>";
$text1.="<caption> </caption>";
$text1.="<input type='text' name='id_tovar' id='id_tovar'
value='".$Id."' ";
//
$query1="SELECT id FROM kategory WHERE id_parent='0'";
$rez1=mysql_query($query1);
$row1=mysql_fetch_row($rez1);
$rezfun=f_regtovar_open_kategory($row1[0]);
$query2="SELECT name FROM kategory WHERE id='".$row0[id_kategory]."'";
$rez2=mysql_query($query2);
$kategory=$row0[id_kategory].";".mysql_result($rez2,0);
$text1.="<tr><td width=30% valign=top></td>
<td width=50%><center>
<input type='text' name='tovar_kategory' id='tovar_kategory'
value='".$kategory."' onchange='xajax_Control_Reg_Tovar
(xajax.getFormValues(\"FormRegTovar\"));'>";
$text1.="<div class='menu' style='margin-left:0'
id=regtovar_kategory1>".$rezfun."</div>";
$text1.="</td>
<td width=20%>
<div id='reg_tovar_kategory'><font color='blue'>ok</font>
</div>
</td></tr>";
//
$text1.="<tr><td width=30% valign=top></td>
<td width=50%><center><img id=new_tovar_img
src='resize_100.php?pic=".$row0[img]."'>
<br><input type='text' name=name_tovar_img id=name_tovar_img
value='".$row0[img]."'>
</center>
<div id='iframe_img'><iframe src='upload_img.php?id=1'
frameborder='0'></iframe></div>
</td>
<td width=20%>
<div id='reg_tovar_img'><font color='blue'>ok</font>
</div>
</td></tr>";
//
$text1.="<tr><td width=30%></td>
<td width=50%><input type='text' name='name' id='name'
334 II. -

size='30' maxlength='50' value='".$row0[name]."' onchange='


xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'></td>
<td width=20%>
<div id='reg_tovar_name'><font color='blue'>ok</font></div>
</td></tr>";
//
$text1.="<tr><td width=30%> </td>
<td width=50%><textarea name='info' id='info'
cols='30' rows='5' value='".$row0[info]."' onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'>
".$row0[info]."</textarea>
</td>
<td width=20%>
<div id='reg_tovar_info'><font color='blue'>ok</font></div>
</td></tr>";
//
$text1.="<tr><td width=30%> </td>
<td width=50%><textarea name='fullinfo' id='fullinfo'
cols='30' rows='5' value='".$row0[fullinfo]."' onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'>
".$row0[fullinfo]."</textarea>
</td>
<td width=20%>
<div id='reg_tovar_fullinfo'><font color='blue'>
ok</font></div>
</td></tr>";
//
$text1.="<tr><td width=30%>, .</td>
<td width=50%><input type='text' name='pay_rub' id='pay_rub'
size='10' maxlength='10' value='".$row0[pay_rub]."'
onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'></td>
<td width=20%>
<div id='reg_tovar_pay_rub'><font color='blue'>
ok</font></div>
</td></tr>";
//
$text1.="<tr><td width=30%> (), .</td>
<td width=50%><input type='text' name='new_pay_rub'
id='new_pay_rub' size='10' maxlength='10'
value='".$row0[new_pay_rub]."' onchange='
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'></td>
4. 335

<td width=20%>
<div id='reg_tovar_new_pay_rub'><font color='blue'>
ok</font></div>
</td></tr>";
//
$text1.="<tr><td width=30% valign=top></td>
<td width=50%><center><img id=new_arhiv_img
src='imgtovar/null.gif'>
<br><input type='text' name=name_tovar_arhiv
id=name_tovar_arhiv value='".$row0[arhiv]."'
onchange='xajax_Control_Reg_Tovar(
xajax.getFormValues(\"FormRegTovar\"));'>
<div id='iframe_arhiv'><iframe src='upload_arhiv.php?id=1'
frameborder='0'></iframe></div>
</center>
</td>
<td width=20%>
<div id='reg_tovar_arhiv'><font color='blue'>ok</font>
</div>
</td></tr>";
$text1.="<tr><td></td>
<td><input type='submit' id='ButtonFormRegTovar'
value=' ->'></td>
<td></td></tr>";
$text1.="</table>";
$text1.="</form>";
return $text1;
}
?>

. 4.8.
336 II. -

-
.
.
.
() ()
(. 4.9).

. 4.9.

Xajax- RegTovar_Open_Kategory
RegTovar_Close_Kategory prgtovars_admin/regtovar_open_
close_kategory.php ( 4.9).

4.9

<?php
//
function RegTovar_Open_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_regtovar_open_kategory($Id);
$objResponse->assign("regtovar_kategory".$Id,"innerHTML",$content);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
//
function RegTovar_Close_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_regtovar_close_kategory($Id);
$objResponse->assign("regtovar_kategory".$Id,"innerHTML",$content);
4. 337

$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

f_regtovar_open_kategory.php f_regtovar_
close_kategory.php, prgtovars_admin/function_
regtovar_kategory.php ( 4.10). /
, (id name) -
() .

4.10

<?php
///
// -
function f_regtovar_open_kategory($Id)
{
require_once("mybaza.php");
$text1="";
//
$query1="SELECT name,id,nn FROM kategory WHERE id='".$Id."'
&& visible='yes' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<a href='javascript:void();' onclick='
xajax_RegTovar_Close_Kategory(".$Id.")'>
<img src='img/close_dir.ico'></a>
<a href='javascript:void();' onclick='
xajax_RegTovar_Close_Kategory(".$Id.")'>
".$row1[name]." (".$row1[nn].")</a>";
$query2="SELECT name,id,nn FROM kategory WHERE id_parent='".$Id."'
&& visible='yes' ";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_assoc($rez2))
{
$query3="SELECT id FROM kategory WHERE id_parent='".$row2[id]."'
&& visible='yes' ";
$rez3=mysql_query($query3);
if(mysql_num_rows($rez3)>0)
{
$text1.="<div class='menu' id='regtovar_kategory".$row2[id]."'>
<span><a href='javascript:void();' onclick='
xajax_RegTovar_Open_Kategory(".$row2[id].")'>
338 II. -

<img src='img/open_dir.ico'></a></span>
<span><a href='javascript:void();' onclick='
xajax_RegTovar_Open_Kategory(".$row2[id].")'>
".$row2[name]." (".$row2[nn].")</a><span></div>";
}
else
{
$text1.="<div class='menu' id='regtovar_kategory".$row2[id]."'>
<a href='javascript:void();' onclick='
document.forms.FormRegTovar.tovar_kategory.value=
\"".$row2[id].";".$row2[name]."\";
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'>
<img src='img/last_dir.ico'></a>
<a href='javascript:void();' onclick='
document.forms.FormRegTovar.tovar_kategory.value=
\"".$row2[id].";".$row2[name]."\";
xajax_Control_Reg_Tovar(xajax.getFormValues(
\"FormRegTovar\"));'>
".$row2[name]." (".$row2[nn].")</a></div>";
}
}
return $text1;
}
//******** *******************
function f_regtovar_close_kategory($Id)
{
require_once("mybaza.php");
$text1="";
//
$query1="SELECT name,id,nn FROM kategory WHERE id='".$Id."'
&& visible='yes' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<a href='javascript:void();' onclick='
xajax_RegTovar_Open_Kategory(".$Id.")'>
<img src='img/open_dir.ico'></a>
<a href='javascript:void();' onclick='
xajax_RegTovar_Open_Kategory(".$Id.")'>
".$row1[name]." (".$row1[nn].")</a>";
return $text1;
}
?>
4. 339

4.2.3.

(. 4.10). xajax- Delete_Tovar,
prgtovars_admin/delete_tovar.php ( 4.11).
, Delete_Tovar tovars
visible=del.
, , , -
.

4.11

<?php
// ( visible='del')
function Delete_Tovar($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
$query2="SELECT id_kategory,visible FROM tovars WHERE id='".$Id."' ";
$visible=mysql_result(mysql_query($query2),0,"visible");
// visible=del
$query1="UPDATE tovars SET visible='del' WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
// , visible='yes'
if($visible=='yes')
{
$id_parent=mysql_result(mysql_query($query2),0,"id_kategory");
while($id_parent>0)
{
$query3="SELECT id,id_parent,nn FROM kategory WHERE
id='".$id_parent."' ";
$rez3=mysql_query($query3);
$id_parent=mysql_result($rez3,0,"id_parent");
$id_kategory=mysql_result($rez3,0,"id");
$nn=mysql_result($rez3,0,"nn");
$new_nn=$nn-1;
$query4="UPDATE kategory SET nn='".$new_nn."' WHERE
id='".$id_kategory."' ";
mysql_query($query4);
}
//
$content=f_open_kategory(1);
$objResponse->assign("kategory1","innerHTML",$content);
340 II. -

}
//
$content=f_view_tovar($Id);
$objResponse->assign("center5","innerHTML",$content);
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 4.10.

4.2.4. ,
, -
, . tovars
visible=no , visible=yes .
/ DoHidden_Tovar
DoVisible_Tovar, prgtovars_admin/
dohidden_tovar.php ( 4.12) prgtovars_admin/dovisible_tovar.php (-
4.13). /
.
4. 341

4.12

<?php
// C
function DoHidden_Tovar($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
// visible=no
$query1="UPDATE tovars SET visible='no' WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
//
$query2="SELECT id_kategory FROM tovars WHERE id='".$Id."' ";
$id_parent=mysql_result(mysql_query($query2),0);
while($id_parent>0)
{
$query3="SELECT id,id_parent,nn FROM kategory WHERE
id='".$id_parent."' ";
$rez3=mysql_query($query3);
$id_parent=mysql_result($rez3,0,"id_parent");
$id_kategory=mysql_result($rez3,0,"id");
$nn=mysql_result($rez3,0,"nn");
$new_nn=$nn-1;
$query4="UPDATE kategory SET nn='".$new_nn."' WHERE
id='".$id_kategory."' ";
mysql_query($query4);
}
// ()
$content=f_open_kategory(1);
$objResponse->assign("kategory1","innerHTML",$content);
//
$content=f_view_tovar($Id);
$objResponse->assign("center5","innerHTML",$content);
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
342 II. -

4.13

<?php
//
function DoVisible_Tovar($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
// visible=no
$query1="UPDATE tovars SET visible='yes' WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
//
$query2="SELECT id_kategory FROM tovars WHERE id='".$Id."' ";
$id_parent=mysql_result(mysql_query($query2),0);
while($id_parent>0)
{
$query3="SELECT id,id_parent,nn FROM kategory WHERE
id='".$id_parent."' ";
$rez3=mysql_query($query3);
$id_parent=mysql_result($rez3,0,"id_parent");
$id_kategory=mysql_result($rez3,0,"id");
$nn=mysql_result($rez3,0,"nn");
$new_nn=$nn+1;
$query4="UPDATE kategory SET nn='".$new_nn."' WHERE
id='".$id_kategory."' ";
mysql_query($query4);
}
// ()
$content=f_open_kategory(1);
$objResponse->assign("kategory1","innerHTML",$content);
//
$content=f_view_tovar($Id);
$objResponse->assign("center5","innerHTML",$content);
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
4. 343


(. 4.11).

. 4.11.

4.3.
:
;
;
;
.

. -
. 4.12.

. 4.12.
344 II. -

Admin_Tek_Kategory, ,
Admin_Open_Kategory Admin_Close_Kategory, -
, prgkategery/admin_open_ close_
kategory.php ( 4.14).

4.14

<?php
//
function Admin_Open_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_admin_open_kategory($Id);
// -
$objResponse->assign("admin_kategory".$Id,"innerHTML",$content);
//
//
$content=f_string_kategory($Id);
$content="<b> :</b><br>".$content;
$content.="<br><a href='javascript:void();' onclick='
xajax_Delete_Admin_Kategory(".$Id.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Rename_Admin_Kategory(".$Id.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Add_Admin_Kategory(".$Id.");'></a>";
//
$objResponse->assign("admin_path_kategory","innerHTML",$content);
$objResponse->script("document.getElementById
('admin_path_kategory').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
//
function Admin_Close_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_admin_close_kategory($Id);
// -
$objResponse->assign("admin_kategory".$Id,"innerHTML",$content);
//
//
4. 345

$content=f_string_kategory($Id);
$content="<b> :</b><br>".$content;
$content.="<br><a href='javascript:void();' onclick='
xajax_Delete_Admin_Kategory(".$Id.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Rename_Admin_Kategory(".$Id.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Add_Admin_Kategory(".$Id.");'></a>";
//
$objResponse->assign("admin_path_kategory","innerHTML",$content);
$objResponse->script("document.getElementById
('admin_path_kategory').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
//
function Admin_Tek_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_string_kategory($Id);
$content="<b> :</b><br>".$content;
$content.="<br><a href='javascript:void();' onclick='
xajax_Delete_Admin_Kategory(".$Id.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Rename_Admin_Kategory(".$Id.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Add_Admin_Kategory(".$Id.");'></a>";
//
$objResponse->assign("admin_path_kategory","innerHTML",$content);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

f_admin_open_kategory
f_admin_close_kategory prgkategery/function_admin_open_close_
kategory.php ( 4.15).

4.15

<?php
///
//******** *******************
//
346 II. -

function f_admin_open_kategory($Id)
{
require_once("mybaza.php");
$text1="";
//
$query1="SELECT name,id,nn FROM kategory WHERE id='".$Id."'
&& visible='yes' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<a href='javascript:void();' onclick='
xajax_Admin_Close_Kategory(".$Id.")'>
<img src='img/close_dir.ico'></a>
<a href='javascript:void();' onclick='
xajax_Admin_Close_Kategory(".$Id.")'>
".$row1[name]." (".$row1[nn].")</a>";
$query2="SELECT name,id,nn FROM kategory WHERE id_parent='".$Id."'
&& visible='yes' ";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_assoc($rez2))
{
$query3="SELECT id FROM kategory WHERE id_parent='".$row2[id]."'
&& visible='yes' ";
$rez3=mysql_query($query3);
if(mysql_num_rows($rez3)>0)
{
$text1.="<div class='menu' id='admin_kategory".$row2[id]."'>
<span><a href='javascript:void();' onclick='
xajax_Admin_Open_Kategory(".$row2[id].")'>
<img src='img/open_dir.ico'></a></span>
<span><a href='javascript:void();' onclick='
xajax_Admin_Open_Kategory(".$row2[id].")'>
".$row2[name]." (".$row2[nn].")</a><span></div>";
}
else
{
$text1.="<div class='menu' id='admin_kategory".$row2[id]."'>
<span><a href='javascript:void();' onclick='
xajax_Admin_Tek_Kategory(".$row2[id].")'>
<img src='img/last_dir.ico'></a></span>
<span><a href='javascript:void();' onclick='
xajax_Admin_Tek_Kategory(".$row2[id].")'>
".$row2[name]." (".$row2[nn].")</a><span></div>";
}
}
return $text1;
}
//******** *******************
4. 347

function f_admin_close_kategory($Id)
{
require_once("mybaza.php");
$text1="";
//
$query1="SELECT name,id,nn FROM kategory WHERE id='".$Id."'
&& visible='yes' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<a href='javascript:void();' onclick='
xajax_Admin_Open_Kategory(".$Id.")'>
<img src='img/open_dir.ico'></a>
<a href='javascript:void();' onclick='
xajax_Admin_Open_Kategory(".$Id.")'>
".$row1[name]." (".$row1[nn].")</a>";
return $text1;
}
?>

4.3.1.
-
, . ,
. .
prgkategery/add_admin_kategory.php ( 4.16) xajax-
Add_Admin_Kategory, (. 4.13).

. 4.13.

4.16

<?php
//
function Add_Admin_Kategory($Id)
{
348 II. -

$objResponse = new xajaxResponse();


$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
$text1="<b> </b>";
$text1.="<form id='FormAdminKategory' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormAdminKategory\").disabled=true;
xajax.$(\"ButtonFormAdminKategory\").value=
\"...\";
xajax_Go_Add_Admin_Kategory(xajax.getFormValues(
\"FormAdminKategory\"));'>";
$text1.="<input type='hidden' name='id_parent' value='".$Id."' >";
$text1.="<br>".f_string_kategory($Id)."--><input type='text'
name='name' value='' ";
$text1.="<br><input type='submit' id='ButtonFormAdminKategory'
value=' ->'> ";
$query1="SELECT id FROM kategory WHERE id_parent='".$Id."' &&
visible='yes' ";
$rez1=mysql_query($query1);
if(mysql_num_rows($rez1)>0)
$text1.=" <input type='button' value='' onclick='
xajax_Admin_Open_Kategory(".$Id.");'></form>";
else
$text1.=" <input type='button' value='' onclick='
xajax_Admin_Tek_Kategory(".$Id.");'></form>";
$objResponse->assign("admin_path_kategory","innerHTML",$text1);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 4.14.
4. 349

.
xajax- Go_Add_Admin_Kategory, -
( -
). (. 4.14).
Go_Add_Admin_Kategory prgkategery/go_add_admin_ kategory.php
( 4.17).

4.17

<?php
//
function Go_Add_Admin_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
//
if(strlen(utftowin($Id[name]))==0)
{
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
//
$query1="INSERT INTO kategory SET id_parent='".$Id[id_parent]."',
name='".utftowin($Id[name])."',nn='0',visible='yes' ";
$rez1=mysql_query($query1);
if(!$rez1)
{
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
//
$parent=$Id[id_parent];
$content=f_admin_open_kategory($parent);
$objResponse->assign("admin_kategory".$parent,"innerHTML",$content);
$content=f_string_kategory($parent);
$content="<b> :</b><br>".$content;
$content.="<br><a href='javascript:void();' onclick='
xajax_Delete_Admin_Kategory(".$parent.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Rename_Admin_Kategory(".$parent.");'>
</a>";
350 II. -

$content.="<br><a href='javascript:void();' onclick='


xajax_Add_Admin_Kategory(".$parent.");'></a>";
$objResponse->assign("admin_path_kategory","innerHTML",$content);
$objResponse->script("document.getElementById
('admin_path_kategory').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}

?>

4.3.2.

. . prgkate-
gery/rename_admin_kategory.php ( 4.18) xajax- Rename_
Admin_Kategory, (. 4.15).

. 4.15.

4.18

<?php
//
function Rename_Admin_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
$text1="<b> </b>";
$text1.="<form id='FormAdminKategory' action='javascript:void(null);'
4. 351

onsubmit='xajax.$(\"ButtonFormAdminKategory\").disabled=true;
xajax.$(\"ButtonFormAdminKategory\").value=
\"...\";
xajax_Go_Rename_Admin_Kategory(xajax.getFormValues(
\"FormAdminKategory\"));'>";
$text1.="<input type='hidden' name='id_kategory' value='".$Id."' ";
$text1.="<br>";
//
$content=f_string_kategory($Id);
$content=substr($content,0,strrpos($content,"->"));
$query0="SELECT name FROM kategory WHERE id='".$Id."' ";
$rez0=mysql_query($query0);
$name=mysql_result($rez0,0);
$text1.=$content."--><input type='text' name='name'
value='".$name."' >";
$text1.="<br><input type='submit' id='ButtonFormAdminKategory'
value=' ->' >";
$query1="SELECT id FROM kategory WHERE id_parent='".$Id."' &&
visible='yes' ";
$rez1=mysql_query($query1);
if(mysql_num_rows($rez1)>0)
$text1.=" <input type='button' value='' onclick='
xajax_Admin_Open_Kategory(".$Id.");'></form>";
else
$text1.=" <input type='button' value='' onclick='
xajax_Admin_Tek_Kategory(".$Id.");'></form>";
$objResponse->assign("admin_path_kategory","innerHTML",$text1);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

.
xajax- Go_Rename_Admin_Kategory, -
(
). (. 4.16).
Go_Rename_Admin_Kategory prgkategery/go_rename_
admin_kategory.php ( 4.19).

4.19

<?php
//
function Go_Rename_Admin_Kategory($Id)
{
352 II. -

$objResponse = new xajaxResponse();


$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
//
if(strlen(utftowin($Id[name]))==0)
{
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
//
$query1="UPDATE kategory SET name='".utftowin($Id[name])."'
WHERE id='".$Id[id_kategory]."' ";
$rez1=mysql_query($query1);
if(!$rez1)
{
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
//
$query2="SELECT id_parent FROM kategory WHERE
id='".$Id[id_kategory]."' ";
$rez2=mysql_query($query2);
$parent=mysql_result($rez2,0);
$content=f_admin_open_kategory($parent);
$objResponse->assign("admin_kategory".$parent,"innerHTML",$content);
$content=f_string_kategory($parent);
$content="<b> :</b><br>".$content;
$content.="<br><a href='javascript:void();' onclick='
xajax_Delete_Admin_Kategory(".$parent.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Rename_Admin_Kategory(".$parent.");'>
</a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Add_Admin_Kategory(".$parent.");'></a>";
$objResponse->assign("admin_path_kategory","innerHTML",$content);
$objResponse->script("document.getElementById
('admin_path_kategory').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
4. 353

. 4.16. gif

4.3.3.
-
. . prgkategery/
delete_admin_kategory.php ( 4.20) xajax- Delete_Admin_
Kategory. , ,
(. 4.17).
, ,
, (. 4.18).
, visible=no,
(. 4.19).

. 4.17.
354 II. -

. 4.18. ,

. 4.19. gif

4.20

<?php
//
function Delete_Admin_Kategory($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
// 1 - , !!!
$query1="SELECT id FROM kategory WHERE id_parent='".$Id."'
4. 355

&& visible='yes' ";


$rez1=mysql_query($query1);
if(mysql_num_rows($rez1)>0)
{
$objResponse->alert(" ,
");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
// 2 - !!!
$query2="SELECT nn FROM kategory WHERE id='".$Id."' ";
$rez2=mysql_query($query2);
if(mysql_result($rez2,0)>0)
{
$objResponse->alert(" ");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
// "" - visible=no
$query3="UPDATE kategory SET visible='no' WHERE id='".$Id."' ";
$rez3=mysql_query($query3);
if(!$rez3)
{
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
//
$query4="SELECT id_parent FROM kategory WHERE id='".$Id."' ";
$rez4=mysql_query($query4);
$parent=mysql_result($rez4,0);
$content=f_admin_open_kategory($parent);
$objResponse->assign("admin_kategory".$parent,"innerHTML",$content);
$content=f_string_kategory($parent);
$content="<b> :</b><br>".$content;
$content.="<br><a href='javascript:void();' onclick='
xajax_Delete_Admin_Kategory(".$parent.");'></a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Rename_Admin_Kategory(".$parent.");'>
</a>";
$content.="<br><a href='javascript:void();' onclick='
xajax_Add_Admin_Kategory(".$parent.");'></a>";
$objResponse->assign("admin_path_kategory","innerHTML",$content);
$objResponse->script("document.getElementById
('admin_path_kategory').scrollIntoView();");
356 II. -

$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

4.4.
, ,
, , "-
" "".
, ,
, ,
.

4.4.1.
-
prgzakaz_admin/view_aal_zakaz_admin.php ( 4.21) xajax-
View_All_Zakaz_Admin,
(. 4.20).

. 4.20.

4.21

<?php
// ()
// $Id -
4. 357

function View_All_Zakaz_Admin($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_all_zakaz_admin($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}

?>


f_view_all_zakaz_admin. -
:
;
, ;
;
, .;
, .;
:
;
;
c:
( );
( );
;
.

f_view_all_zakaz, prgzakaz_admin/function_view_all_
zakaz.php ( 4.22). NN2
my.php.

4.22

<?php
// ( ) ()
358 II. -

// $Id -
function f_view_all_zakaz_admin($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text=array();
$text1="";
$query0="SELECT COUNT(id) FROM zakaz WHERE visible='yes'
ORDER BY data DESC ";
$rez0=mysql_query($query0);
$count=mysql_result($rez0,0);
$pages=ceil($count/NN2);
$page=min($Id,$pages);$poz=($page-1)*NN2;
$text1.="<div class='zag_view_tovars'>";
if($count>0)
{
$query1="SELECT * FROM zakaz WHERE visible='yes'
ORDER BY data DESC LIMIT ".$poz.", ".NN2."";
$rez1=mysql_query($query1);
//
$text1.="<table>";
$text1.="<tr><td class='str0' align=right></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td></tr>";$i=0;
while($row1=mysql_fetch_assoc($rez1))
{$i++;
//
$text1.="<tr><td class='str".($i%2+1)."'
align=right>".$row1[id]."</td>";
$query3="SELECT login FROM users WHERE id='".$row1[id_user]."' ";
$rez3=mysql_query($query3);
$login=mysql_result($rez3,0);
//
$login=(strlen($login)<13)?($login):(substr($login,0,12)."...");
//
$text1.="<td class='str".($i%2+1)."'>".$login."</td>";
//
$text1.="<td class='str".($i%2+1)."'>".$row1[data]."</td>";
//
4. 359

$text1.="<td class='str".($i%2+1)."'
align=right>".$row1[summa_rub]."</td>";
//
$text1.="<td class='str".($i%2+1)."'
align=right>".$row1[summa_rub_oplata]."</td>";
//
if($row1[pay]=='yes')
$text1.="<td class='str".($i%2+1)."' align=right><font
color='blue'></font></td>";
else
$text1.="<td class='str".($i%2+1)."' align=right><font
color='red'></font></td>";
$text1.="<td class='str".($i%2+1)."' align=right>";
//
if($row1[pay]=='no')
{
$text1.="<a href='javascript:void();' onclick='
xajax_Oplata_Zakaz_Admin(".$row1[id].");'
title=''><img src='img/pay.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Edit_Zakaz_Admin(".$row1[id].");'
title=''><img src='img/edit.png'></a>";
}
$text1.="<a href='javascript:void();' onclick='
xajax_View_Zakaz_Admin(".$row1[id].");'
title=''><img src='img/view.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Delete_Zakaz_Admin(".$row1[id].");'
title=''><img src='img/delete.png'></a>";
$text1.="</td></tr>";
}
$text1.="</table>";
//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page-1).";
xajax_View_All_Zakaz_Admin(x);'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,5);
for($i=0;$i < count($x);$i++)
360 II. -

//for($i=1;$i <= $pages;$i++)


{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".$x[$i].";
xajax_View_All_Zakaz_Admin(x);'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page+1).";
xajax_View_All_Zakaz_Admin(x);'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count." - ".$pages."<br> </center>";}
else
{$text2.="</center>";}
}
}
else
{
$text2="<br><center> </center><br>";
}
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>

4.4.2.
. 4.21. -
:
;
();
;
().
f_form_search_zakaz_admin, -
prgzakaz_admin/function_form_search_ zakaz_admin (-
4.23).
4. 361

. 4.21.

4.23

<?php
// c (admin)
function f_form_search_zakaz_admin()
{
//
require_once("my.php");
//
require_once("mybaza.php");
//
$text1.="<form id='FormSearchZakaz' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormSearchZakaz\").disabled=true;
xajax.$(\"ButtonFormSearchZakaz\").value=\"...\";
xajax_View_Search_Zakaz_Admin(xajax.getFormValues(
\"FormSearchZakaz\"));'>";
$text1.="<table width=100%>";
//
$text1.="<tr><td width=50%> </td>";
$text1.="<td width=50%>
<input type='text' name='user_zakaz' value='' size=32
maxlength=32>
<input type='hidden' id='pagesearch' name='pagesearch'
value='1'></td></tr>";
$text1.="<tr><td width=50%><b></b></td></td></tr>";
//
$text1.="<tr><td width=50%> </td>";
$text1.="<td width=50%>
<input type='text' name='number_zakaz' value='' size=5
maxlength=5></td></tr>";
$text1.="<tr><td width=50%><b> </b></td></td></tr>";
362 II. -

//
$text1.="<tr><td width=50%> </td>";
$text1.="<td width=50%>
<input type='text' name='datazakaz1' id='datazakaz1'
value='".date('Y-m-d')."' size=10 maxlength=10></td></tr>";
//
$text1.="<tr><td width=50%> </td>";
$text1.="<td width=50%>
<input type='text' name='datazakaz2' id='datazakaz2'
value='".date('Y-m-d',strtotime('now +1 day'))."' size=10
maxlength=10></td></tr>";
//
$text1.="<tr><td width=50%> ( )</td>";
$text1.="<td width=50%>
<input type='text' name='name_tovar' value='' size=20
maxlength=20></td></tr>";
$text1.="</table>";
$text1.="<center><br><input type='submit' id='ButtonFormSearchZakaz'
value=' ->'></center>";
$text1.="</form>";
return $text1;
}
?>

, prgza-
kaz_admin/view_search_zakaz_admin.ph ( 4.24) xajax-
View_Search_Zakaz_Admin,
FormSearchZakaz. .

4.24

<?php
// ()
function View_Search_Zakaz_Admin($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$zag=f_zag1(" ");
$objResponse->assign("centercaption3","innerHTML",$zag);
//
$content=f_view_search_zakaz_admin($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
4. 363

// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
// submit
$objResponse->assign("ButtonFormSearchZakaz","value", " ->");
$objResponse->assign("ButtonFormSearchZakaz","disabled", false);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>


f_view_search_zakaz_admin, prgza-
kaz_admin/ function_view_search_zakaz_admin.php ( 4.25). -
. 4.22.

. 4.22.

4.25

<?php
//
// $Id -
function f_view_search_zakaz_admin($Id)
{
//
require_once("my.php");
364 II. -

//
require_once("mybaza.php");
$text=array();
$text1="";
//
$query0="SELECT DISTINCT(zakaz.id) FROM zakaz,zakaz_table,tovars WHERE
zakaz.visible='yes' ";
$name_tovar=utftowin($Id[name_tovar]);
if(strlen(trim($Id[user_zakaz]))>0)
{
$query0="SELECT DISTINCT(zakaz.id)FROM zakaz,zakaz_table,tovars,users
WHERE zakaz.visible='yes' ";
$query0.="&& zakaz.id_user=users.id && LOWER(users.login) LIKE
'%".$Id[user_zakaz]."%' ";
}
elseif($Id[number_zakaz]>0)
{
$query0.="&& zakaz.id='".$Id[number_zakaz]."' ";
}
else
{
$query0.="&& zakaz.data >= '".$Id[datazakaz1]."' &&
zakaz.data <='".$Id[datazakaz2]."' ";
if(strlen(rtrim(ltrim($name_tovar)))>0)
{
$query0.="&& LOWER(tovars.name) LIKE '%".$name_tovar."%' &&
zakaz_table.id_tovar=tovars.id
&& zakaz_table.id_zakaz=zakaz.id ";
}
}
$rez0=mysql_query($query0);
$count=mysql_num_rows($rez0);
$pages=ceil($count/NN2);
$page=min($Id[pagesearch],$pages);$poz=($page-1)*NN2;
$text1="<div class='zag_view_tovars'>";
if($count>0)
{
$query0.=" LIMIT ".$poz.", ".NN2."";
$query1=$query0;
$rez1=mysql_query($query1);
//
$text1.="<table>";
$text1.="<tr><td class='str0' align=right></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td>";
4. 365

$text1.="<td class='str0' align=right><br></td>";


$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0'></td></tr>";$i=0;
while($row1=mysql_fetch_row($rez1))
{$i++;
$query2="SELECT * FROM zakaz WHERE id='".$row1[0]."' ";
$rez2=mysql_query($query2);
$row2=mysql_fetch_assoc($rez2);
$text1.="<tr><td class='str".($i%2+1)."'
align=right>".$row2[id]."</td>";
$query3="SELECT login FROM users WHERE id='".$row2[id_user]."' ";
$rez3=mysql_query($query3);
$login=mysql_result($rez3,0);
//
$login=(strlen($login)<13)?($login):(substr($login,0,12)."...");
$text1.="<td class='str".($i%2+1)."'>".$login."</td>";
//
$text1.="<td class='str".($i%2+1)."'>".$row2[data]."</td>";
//
$text1.="<td class='str".($i%2+1)."'
align=right>".$row2[summa_rub]."</td>";
//
$text1.="<td class='str".($i%2+1)."'
align=right>".$row2[summa_rub_oplata]."</td>";
//
if($row2[pay]=='yes')
$text1.="<td class='str".($i%2+1)."' align=right><font
color='blue'></font></td>";
else
$text1.="<td class='str".($i%2+1)."' align=right><font
color='red'></font></td>";
$text1.="<td class='str".($i%2+1)."' align=right>";
//
if($row2[pay]=='no')
{
$text1.="<a href='javascript:void();' onclick='
xajax_Oplata_Zakaz_Admin(".$row2[id].");'
title=''><img src='img/pay.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Edit_Zakaz_Admin(".$row2[id].");'
title=''><img src='img/edit.png'></a>";
}
$text1.="<a href='javascript:void();' onclick='
xajax_View_Zakaz_Admin(".$row2[id].");'
366 II. -

title=''><img src='img/view.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Delete_Zakaz_Admin(".$row2[id].");'
title=''><img src='img/delete.png'></a>";
$text1.="</td></tr>";
}
$text1.="</table>";
//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchZakaz.pagesearch.value=".$i.";
xajax_View_Search_Zakaz_Admin(xajax.getFormValues(
\"FormSearchZakaz\"));'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,5);
for($i=0;$i < count($x);$i++)
//for($i=1;$i <= $pages;$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchZakaz.pagesearch.value=".$x[$i].";
xajax_View_Search_Zakaz_Admin(xajax.getFormValues(
\"FormSearchZakaz\"));'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchZakaz.pagesearch.value=".$i.";
xajax_View_Search_Zakaz_Admin(xajax.getFormValues(
\"FormSearchZakaz\"));'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count." - ".$pages."<br>
</center>";}
else
{$text2.="</center>";}
4. 367

}
}
else
{
$text2="<br><center>
</center><br>";
}
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>

4.4.3.
-
(. 4.23). xajax- View_Zakaz_Admin, -
prgzakaz_admin/view_zakaz_admin.php ( 4.26).
ID zakaz .

4.26

<?php
// ()
// $Id - id
function View_Zakaz_Admin($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_zakaz_admin($Id);
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$content);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
368 II. -

. 4.23.

f_view_zakaz_admin,
prgzakaz_admin/function_view_zakaz_admin.php (-
4.27). zakaz_table.

4.27

<?php
// ()
// $Id - id
function f_view_zakaz_admin($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text=array();
$text1="";
//
$query1="SELECT * FROM zakaz WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
//
$text1.="<br><b></b> ".$row1[id]."<br>";
$query3="SELECT login FROM users WHERE id='".$row1[id_user]."' ";
$rez3=mysql_query($query3);
//
$text1.="<br><b></b> ".mysql_result($rez3,0)."<br>";
//
if($row1[pay]=='yes')
$text1.="<b> </b> - <br>";
else
$text1.="<b> </b> - <br><br>";
4. 369

//
$query2="SELECT * FROM zakaz_table WHERE id_zakaz='".$Id."' ";
$rez2=mysql_query($query2);
//
$text1.="<table>";
$text1.="<tr><td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right>-</td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0'></td>";
$text1.="</tr>";
$i=0;$count=0;
while($row2=mysql_fetch_assoc($rez2))
{$i++;
$text1.="<tr><td class='str".($i%2+1)."' align=right>".$i."</td>";
$query3="SELECT name FROM tovars WHERE id='".$row2[id_tovar]."' ";
//
$rez3=mysql_query($query3);
$text1.="<td class='str".($i%2+1)."'>
".mysql_result($rez3,0)."</td>";
//
$text1.="<td class='str".($i%2+1)."' align=right>
".$row2[kol]."</td>";
//
$count+=$row2[kol];
//
$text1.="<td class='str".($i%2+1)."' align=right>
".$row2[pay_rub]."</td>";
//
$text1.="<td class='str".($i%2+1)."' align=right>
".$row2[summa_rub]."</td>";
//
if($row2[id_link]>0)
$text1.="<td class='str".($i%2+1)."'><a href='download.php?
id=".$row2[id_link]."' target='_blank'>
<img src='img/download.png'></a></td></tr>";
else
$text1.="<td class='str".($i%2+1)."'></td>";
$text1.="</tr>";
}
$text1.="<tr><td></td>";
$text1.="<td></td>";
//
$text1.="<td align=right>".$count."</td>";
370 II. -

$text1.="<td align=right></td>";
//
$text1.="<td align=right>".$row1[summa_rub]."</td>";
$text1.="<td></td></tr>";
if($row1[pay]=='no')
{
$text1.="<tr><td></td>";
$text1.="<td></td>";
$text1.="<td align=right></td>";
$text1.="<td align=right></td>";
$text1.="<td align=right>".$row1[summa_rub_oplata]."</td>";
$text1.="<td></td></tr>";
}
$text1.="</table>";
//
if($row1[pay]=='no')
$text1.="<br><br><input type=button value=' '
onclick='xajax_Oplata_Zakaz_Admin(".$row1[id].");' >";
return $text1;
}
?>

4.4.4.
( ) -
(. 4.24). xajax-
Edit_Zakaz_Admin, prgzakaz_admin/ edit_zakaz_
admin.php ( 4.28). ID
zakaz .

4.28

<?php
// - admin
function Edit_Zakaz_Admin($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_edit_zakaz_admin($Id);
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$content);
4. 371

// center5
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 4.24.

f_edit_zakaz_admin,
prgzakaz_admin/function_edit_zakaz_admin.php (-
4.29). FormEditZakaz,
zakaz_table. , onchange -
xajax- Change_Kol_Table .
onchange xajax- Change__Table
.
xajax- Change_Kol_Table -
, .

4.29

<?php
// - admin
// $Id - id
function f_edit_zakaz_admin($Id)
372 II. -

{
//
require_once("my.php");
//
require_once("mybaza.php");
//
$text1="";
$text1.="<form id='FormEditZakaz' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormEditZakaz\").disabled=true;
xajax.$(\"ButtonFormEditZakaz\").value=
\"...\";
xajax_Go_Edit_Zakaz_Admin(xajax.getFormValues(
\"FormEditZakaz\"));'>";
$text1.="<table width=100%>";
$query1="SELECT * FROM zakaz WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<br><br><b></b> ".$row1[id]."<br>";
$query11="SELECT login FROM users WHERE id='".$row1[id_user]."' ";
$rez11=mysql_query($query11);
$text1.="<br><br><b> - </b> ".mysql_result($rez11,0)."<br>";
if($row1[pay]=='yes')
$text1.="<br><b> </b> - <br>";
else
$text1.="<br><b> </b> - <br>";
$query2="SELECT * FROM zakaz_table WHERE id_zakaz='".$Id."' ";
$rez2=mysql_query($query2);
//
$text1.="<table>";
$text1.="<tr><td class='str0'></td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right>-</td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0' align=right>,<br></td>";
$text1.="<td class='str0'></td>";
$text1.="</tr>";
$i=0;$count=0;
//
while($row2=mysql_fetch_assoc($rez2))
{$i++;$count+=$row2[kol];
$text1.="<tr>";
$text1.="<td class='str".($i%2+1)."' width=5%>".$i."
<input type=hidden name=table_id".$i." id=table_id".$i."
value='".$row2[id]."' ></td>";
$query1="SELECT name FROM tovars WHERE id='".$row2[id_tovar]."' ";
4. 373

$text1.="<td class='str".($i%2+1)."'
width=60%>".mysql_result(mysql_query($query1),0)."</td>";
$text1.="<td class='str".($i%2+1)."' width=10%><input type=text
name=table_kol".$row2[id]." id=table_kol".$row2[id]."
value='".$row2[kol]."' size=3 maxlength=3 ".READONLYZ."
onchange='var x=new Array();x[0]=".$row2[id].";x[1]=this.value;
x[2]=document.forms.FormEditZakaz.table_pay".$row2[id].".value;
x[3]=document.forms.FormEditZakaz.table_summa".$row2[id].".value;
x[4]=document.forms.FormEditZakaz.itogo_count_zakaz.value;
x[5]=document.forms.FormEditZakaz.itogo_summa_zakaz.value;
xajax_Change_Kol_Table(x);'>
</td>";
$text1.="<td class='str".($i%2+1)."' width=10%><input type=text
name=table_pay".$row2[id]." id=table_pay".$row2[id]."
value='".$row2[pay_rub]."' size=3 maxlength=6
onchange='var x=new Array();x[0]=".$row2[id].";
x[1]=document.forms.FormEditZakaz.table_kol".$row2[id].".value;
x[2]=this.value;
x[3]=document.forms.FormEditZakaz.table_summa".$row2[id].".value;
x[4]=document.forms.FormEditZakaz.itogo_count_zakaz.value;
x[5]=document.forms.FormEditZakaz.itogo_summa_zakaz.value;
xajax_Change_Pay_Table(x);'>
</td>";
$text1.="<td class='str".($i%2+1)."' width=10%><input type=text
name=table_summa".$row2[id]." id=table_summa".$row2[id]."
value='".$row2[summa_rub]."' size=6 maxlength=6 readonly
onclick='document.getElementById(
\"table_kol".$row2[id]."\").focus();return false;' >
</td>";
if(READONLYZ=='readonly')
$text1.="<td class='str".($i%2+1)."' width=5%><a
href='javascript:void();' onclick='
var x=new Array();x[0]=".$row2[id].";x[1]=\"0\";
x[2]=document.forms.FormEditZakaz.table_pay".$row2[id].".value;
x[3]=document.forms.FormEditZakaz.table_summa".$row2[id].".value;
x[4]=document.forms.FormEditZakaz.itogo_count_zakaz.value;
x[5]=document.forms.FormEditZakaz.itogo_summa_zakaz.value;
xajax_Change_Kol_Table(x);'><img src='img/delete.png'>
</a></td>";
$text1.="</tr>";
}
$text1.="<tr><td></td>";
$text1.="<td></td>";
$text1.="<td align=right><input type=text name=itogo_count_zakaz
id=itogo_count_zakaz
374 II. -

value='".$count."' size=8 maxlength=8 readonly></td>";


$text1.="<td align=right></td>";
$text1.="<td align=right><input type=text name=itogo_summa_zakaz
id=itogo_summa_zakaz value='".$row1[summa_rub]."' size=8 maxlength=8
readonly></td>";
$text1.="<td></td></tr>";
$text1.="</table>";
$text1.="<center><input type='submit' id='ButtonFormEditZakaz'
value=' ->'>
<br><br><input type='button' value='' onclick='
document.getElementById(\"center5\").innerHTML=\"\";
document.getElementById(\"centercaption5\").innerHTML=\"\";'>
</center>";
$text1.="</form>";
return $text1;
}
?>

Xajax- Change_Kol_Table (. 3.71). -


Change__Table, prgzakaz/change_
pay_table.php ( 4.30). ID , , -
, , -
.

4.30

<?php
//
// - admin
function Change_Pay_Table($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$new_summa=$Id[1]*$Id[2];
$objResponse->assign("table_summa".$Id[0],"value",$new_summa);
//
$new_itogo_summa=$Id[5]-$Id[3]+$Id[1]*$Id[2];
$objResponse->assign("itogo_summa_zakaz","value",$new_itogo_summa);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

prgzakaz_admin/go_edit_
zakaz_admin.php, ( 4.31) xajax- Go_Edit_Zakaz
4. 375

c FormEditZakaz.

zakaz_table, zakaz.
(. 4.25).

. 4.25.

4.31

<?php
//
function Go_Edit_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
$j=(count($Id)-2)/4;
for($i=1;$i<=$j;$i++)
{
$id=$Id[table_id.$i];
$kol=$Id[table_kol.$id];
$summa_rub=$Id[table_summa.$id];
$query1="UPDATE zakaz_table SET kol='".$kol."',
summa_rub='".$summa_rub."'
WHERE id='".$id."' ";
376 II. -

$rez1=mysql_query($query1);
}
$objResponse->alert(" !!!");
// zakaz
$query2="SELECT id_zakaz FROM zakaz_table WHERE id='".$id."' ";
$id_zakaz=mysql_result(mysql_query($query2),0);
$query3="UPDATE zakaz SET summa_rub='".$Id[itogo_summa_zakaz]."'
WHERE id='".$id_zakaz."' ";
mysql_query($query3);
//
$content=f_edit_zakaz($id_zakaz);
$zagcontent=f_zag1(" ");
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
$objResponse->assign("center5","innerHTML",$content);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

4.4.5.
. -
xajax- Delete_Zakaz_Admin, prgzakaz_
admin/delete_ zakaz_admin.php ( 4.32).
ID zakaz . -
(. 4.26). , -
zakaz visible=no,
.

. 4.26.
4. 377

4.32

<?php
//
function Delete_Zakaz($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
// visible=no
$query1="UPDATE zakaz SET visible='no' WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
if($rez1)
{
$objResponse->alert(" !!!");
//
$content=f_view_all_zakaz(1);
$objResponse->assign("center3","innerHTML",$content[0]);
$objResponse->assign("center4","innerHTML",$content[1]);
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
$objResponse->assign("centercaption5","innerHTML","<table></table>");
$objResponse->assign("center5","innerHTML","<table></table>");
}
else
$objResponse->alert(" !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

4.4.6.
"-
". zakaz
pay=yes. xajax-
Oplata_Zakaz_Admin, prgoplata/oplata_
zakaz_admin.php ( 4.33). pay=yes
(. 4.27). -

link_downloads create_htaccess
, .
378 II. -

. 4.27.

4.33

<?php
// admin
// pay=yes
function Oplata_Zakaz_Admin($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
//
$query1="UPDATE zakaz SET pay='yes' WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
//
$data=date('Y-m-d',strtotime('now+10days'));
$query2="SELECT id,id_tovar FROM zakaz_table WHERE id_zakaz=".$Id." ";
$rez2=mysql_query($query2);
while($row2=mysql_fetch_assoc($rez2))
{
$query3="SELECT arhiv FROM tovars WHERE id='".$row2[id_tovar]."' ";
$link=mysql_result(mysql_query($query3),0);
$query4="SELECT id_user FROM zakaz WHERE id='".$Id."' ";
$id_user=mysql_result(mysql_query($query4),0);
$query5="INSERT INTO link_downloads SET id_user='".$id_user."',
file='".$link."',status='yes',data='".$data."',id_zakaz='".$Id."' ";
$rez5=mysql_query($query5);
$id_link=mysql_insert_id();
4. 379

$query6="UPDATE zakaz_table SET id_link='".$id_link."'


WHERE id='".$row2[id]."' ";
$rez6=mysql_query($query6);
}
// .htaccess
create_new_htaccess();
//
if($rez1)
{
$objResponse->alert(" !!!");
//
$content.=f_view_zakaz_admin($Id);
$objResponse->assign("center5","innerHTML",$content);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
}
else
$objResponse->alert(" admin !!!");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

4.5.
:
;
;
;
.

4.5.1.
,
(. 4.28).
:
;
;
:
;
;
;
380 II. -

c:
yes ;
no ;
del .
IP-;
:
;
;
.

. 4.28.

f_view_all_users
, .
users. prgusers_admin/function_
view_all_users.php ( 4.34).

4.34

<?php
// ()
// $Id -
function f_view_all_users($Id)
4. 381

{
require_once("my.php");
require_once("mybaza.php");
$text=array();
$text1="";
//
$query0="SELECT COUNT(id) FROM users ORDER BY id ASC ";
$rez0=mysql_query($query0);
$count=mysql_result($rez0,0);
$pages=ceil($count/NN4);
$page=min($Id,$pages);$poz=($page-1)*NN4;
$text1.="<div class='zag_view_tovars'>";
if($count>0)
{
//
$query1="SELECT * FROM users ORDER BY id
ASC LIMIT ".$poz.", ".NN4."";
$rez1=mysql_query($query1);
//
$text1.="<table>";
$text1.="<tr><td class='str0' align=right>Id</td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0' align=right></td>";
$text1.="<td class='str0' align=right></td>";
$text1.="<td class='str0' align=right>ip</td>";
$text1.="<td class='str0'></td></tr>";$i=0;
$arrtype=array("","","User","","","","","","","");
while($row1=mysql_fetch_assoc($rez1))
{$i++;
$text1.="<tr><td class='str".($i%2+1)."' align=right>
".$row1[id]."</td>";
//
$text1.="<td class='str".($i%2+1)."'>".$row1[data]."</td>";
$login=$row1[login];
$login=(strlen($login)<13)?($login):(substr($login,0,12)."...");
//
$text1.="<td class='str".($i%2+1)."' align=right>".$login."</td>";
//
$text1.="<td class='str".($i%2+1)."' align=right>
".$arrtype[$row1[type]]."</td>";
//
$text1.="<td class='str".($i%2+1)."' align=right>
".$row1[visible]."</td>";
// ip
382 II. -

$text1.="<td class='str".($i%2+1)."' align=right>


".str_replace(";","<br>",$row1[ip])."</td>";
$text1.="<td class='str".($i%2+1)."' align=right>";
//
$text1.="<a href='javascript:void();' onclick='
xajax_View_User_Admin(".$row1[id].");'
title=''><img src='img/view.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Edit_User_Admin(".$row1[id].");'
title=''><img src='img/edit.png'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Delete_User_Admin(".$row1[id].");'
title=''><img src='img/delete.png'></a>";
$text1.="</td></tr>";
}
$text1.="</table>";
//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page-1).";
xajax_View_All_Users(x);'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,5);
for($i=0;$i < count($x);$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".$x[$i].";
xajax_View_All_Users(x);'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
var x=new Array();x=".($page+1).";
xajax_View_All_Users(x);'> >></a>";
}
4. 383

if($pages != 1)
{$text2.="<br><br> - ".$count." - ".$pages."<br>
</center>";}
else
{$text2.="</center>";}
}
}
else
{
$text1="<br><center> </center><br>";
}
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>

4.5.2.
. 4.29.
f_form_search_users, prgusers_admin/
function_form_search_users.php ( 4.35). -
:
;
IP-;
;
;
, ( ).

4.35

<?php
//
function f_form_search_users()
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text1.="<form id='FormSearchUsers' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormSearchUsers\").disabled=true;
xajax.$(\"ButtonFormSearchUsers\").value=\"...\";
xajax_View_Search_Users(xajax.getFormValues(
384 II. -

\"FormSearchUsers\"));'>";
$text1.="<table width=100%>";
$text1.="<tr><td width=50%><b> </b></td></td></tr>";
//
$text1.="<tr><td width=50%></td>";
$text1.="<td width=50%>
<input type='text' name='login' value='' size=32 maxlength=32>
<input type='hidden' id='pagesearch' name='pagesearch'
value='1'></td></tr>";
$text1.="<tr><td width=50%>IP - </td>";
// ip
$text1.="<td width=50%>
<input type='text' name='ip' value='' size=16
maxlength=16></td></tr>";
//
$text1.="<tr><td width=50%></td>";
$text1.="<td width=50%><select name=type>
<option value='0' selected>
<option value='1'>
<option value='2'>User
<option value='9'>
</select></td></tr>";
//
$text1.="<tr><td width=50%></td>";
$text1.="<td width=50%><select name=visible>
<option value='all' selected>
<option value='yes'>yes
<option value='no'>no
<option value='block'>block
</select></td></tr>";
//
$text1.="<tr><td width=50%><b> </b></td></td></tr>";
$text1.="<tr><td width=50%> ( )</td>";
$text1.="<td width=50%>
<input type='text' name='name_tovar' value='' size=20
maxlength=20></td></tr>";
$text1.="</table>";
$text1.="<center><br><input type='submit' id='ButtonFormSearchUsers'
value=' ->'></center>";
$text1.="</form>";
return $text1;
}
?>
4. 385

. 4.29.

prgusers_admin/view_search_users.php,
( 4.36) xajax- View_Search_Users,
FormSearchUsers.

4.36

<?php
//
function View_Search_Users($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$zag=f_zag1(" ");
//
$objResponse->assign("centercaption3","innerHTML",$zag);
//
$content=f_view_search_users($Id);
//
$objResponse->assign("center3","innerHTML",$content[0]);
//
$objResponse->assign("center4","innerHTML",$content[1]);
// center3
$objResponse->script("document.getElementById
('center3').scrollIntoView();");
//
$objResponse->assign("ButtonFormSearchUsers","value", " ->");
$objResponse->assign("ButtonFormSearchUsers","disabled", false);
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>
386 II. -

f_view_search_users, -
prgusers_admin/function_view_ search_users.php ( 4.37).

4.37

<?php
//
// $Id -
function f_view_search_users($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
$text=array();
$text1="";
$name_tovar=utftowin($Id[name_tovar]);
$login=utftowin($Id[login]);
$ip=utftowin($Id[ip]);
$type=$Id[type];
$visible=$Id[visible];
//
if(strlen(rtrim(ltrim($name_tovar)))>0)
{ //
$query0="SELECT DISTINCT(users.id) FROM
zakaz,zakaz_table,tovars,users
WHERE zakaz.visible='yes' && zakaz.id_user=users.id &&
LOWER(tovars.name) LIKE '%".$name_tovar."%' &&
zakaz_table.id_tovar=tovars.id && zakaz_table.id_zakaz=zakaz.id ";
}
else
{ //
$query0="SELECT id FROM users WHERE id>0 ";
if(strlen(rtrim(ltrim($login)))>0)
{
$query0.="&& LOWER(login) LIKE '%".$login."%' ";
}
if(strlen(rtrim(ltrim($ip)))>0)
{
$query0.="&& ip LIKE '%".$ip."%' ";
}
if($type>0)
{
$query0.="&& type='".$type."' ";
}
4. 387

if($visible!='all')
{
$query0.="&& visible='".$visible."' ";
}
}
$rez0=mysql_query($query0);
$count=mysql_num_rows($rez0);
$pages=ceil($count/NN4);
$page=min($Id[pagesearch],$pages);$poz=($page-1)*NN4;
$text1="<div class='zag_view_tovars'>";
if($count>0)
{ //
$query0=$query0." LIMIT ".$poz.", ".NN4." ";
$rez0=mysql_query($query0);
//
$text1.="<table>";
$text1.="<tr><td class='str0' align=right>Id</td>";
$text1.="<td class='str0'></td>";
$text1.="<td class='str0' align=right><br></td>";
$text1.="<td class='str0' align=right></td>";
$text1.="<td class='str0' align=right></td>";
$text1.="<td class='str0' align=right>ip</td>";
$text1.="<td class='str0'></td></tr>";$i=0;
$arrtype=array("","","User","","","","","","","");
while($row0=mysql_fetch_row($rez0))
{$i++;
$query1="SELECT * FROM users WHERE id='".$row0[0]."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<tr><td class='str".($i%2+1)."'
align=right>".$row1[id]."</td>";
//
$text1.="<td class='str".($i%2+1)."'>".$row1[data]."</td>";
$login=$row1[login];
$login=(strlen($login)<13)?($login):(substr($login,0,12)."...");
//
$text1.="<td class='str".($i%2+1)."' align=right>".$login."</td>";
//
$text1.="<td class='str".($i%2+1)."'
align=right>".$arrtype[$row1[type]]."</td>";
//
$text1.="<td class='str".($i%2+1)."'
align=right>".$row1[visible]."</td>";
// ip
$text1.="<td class='str".($i%2+1)."'
388 II. -

align=right>".str_replace(";","<br>",$row1[ip])."</td>";
$text1.="<td class='str".($i%2+1)."' align=right>";
//
$text1.="<a href='javascript:void();' onclick='
xajax_View_User_Admin(".$row1[id].");'
title=''><img src='img/view.gif'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Edit_User_Admin(".$row1[id].");'
title=''><img src='img/edit.png'></a>";
$text1.="<a href='javascript:void();' onclick='
xajax_Delete_User_Admin(".$row1[id].");'
title=''><img src='img/delete.png'></a>";
$text1.="</td></tr>";
}
$text1.="</table>";
//
$text2="";
if($pages>1)
{
if($page != 1)
{$i=$page-1;
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchUsers.pagesearch.value=".$i.";
xajax_View_Search_Users(xajax.getFormValues(
\"FormSearchUsers\"));'> <<</a>";
}
$x=array();
$x=doarray1($page,$pages,5);
for($i=0;$i < count($x);$i++)
//for($i=1;$i <= $pages;$i++)
{
if($x[$i]==$page)
$text2.="<a> ".$x[$i]."</a>";
else
{
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchUsers.pagesearch.value=".$x[$i].";
xajax_View_Search_Users(xajax.getFormValues(
\"FormSearchUsers\"));'> ".$x[$i]."</a>";
}
}
if($page != $pages)
{$i=$page+1;
$text2.="<a href='javascript:void(null);' onclick='
document.forms.FormSearchUsers.pagesearch.value=".$i.";
4. 389

xajax_View_Search_Users(xajax.getFormValues(
\"FormSearchUsers\"));'> >></a>";
}
if($pages != 1)
{$text2.="<br><br> - ".$count." - ".$pages."<br>
</center>";}
else
{$text2.="</center>";}
}
}
else
{
$text2="<br><center>
</center><br>";
}
$text[0]=$text1;
$text[1]=$text2;
return $text;
}
?>

4.5.3.
-
(. 4.30). xajax- View_User_Admin,
prgusers_admin/view_user_admin.php ( 4.38). -
ID users.

4.38

<?php
//
// $Id - id
function View_User_Admin($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_view_user_admin($Id);
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$content);
// center5
390 II. -

$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 4.30.

f_view_user_admin, prgus-
ers_admin/function_view_user_admin.php ( 4.39).
users zakaz. :
;
;
;
;
;
e-mail ;
;
IP- ;
;
;
.

4.39

<?php
//
// $Id - id
function f_view_user_admin($Id)
4. 391

{
require_once("my.php");
require_once("mybaza.php");
$text=array();
$text1="";
// users
$query1="SELECT * FROM users WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<table>";
$text1.="<tr><td></td><td>".$row1[login]."</td></tr>";
$text1.="<tr><td></td><td>".$row1[password]."</td></tr>";
$text1.="<tr><td> </td><td>".$row1[data]."</td></tr>";
$arrtype=array("","","User","","","","","","","");
$text1.="<tr><td>
</td><td>".$arrtype[$row1[type]]."</td></tr>";
$text1.="<tr><td></td><td>".$row1[visible]."</td></tr>";
$text1.="<tr><td>E-mail</td><td>".$row1[email]."</td></tr>";
$text1.="<tr><td></td><td>".$row1[vizits]."</td></tr>";
$text1.="<tr><td valign=top>IP-
</td><td>".str_replace(';','<br>',$row1[ip])."</td></tr>";
$text1.="<tr><td></td><td>".$row1[discount]." %</td></tr>";
//
$query2="SELECT COUNT(id) FROM zakaz WHERE id_user='".$Id."' ";
$rez2=mysql_query($query2);
$text1.="<tr><td>,
</td><td>".mysql_result($rez2,0)."</td></tr>";
//
$query3="SELECT COUNT(id) FROM zakaz WHERE id_user='".$Id."'
&& pay='yes' ";
$rez3=mysql_query($query3);
$text1.="<tr><td>
</td><td>".mysql_result($rez3,0)."</td></tr>";
$text1.="</table>";
return $text1;
}
?>

4.5.4.

(. 4.31). xajax-
Edit_User_Admin, prgusers_admin/edit_user_
admin.php ( 4.40). ID
users.
392 II. -

4.40

<?php
//
// $Id - id
function Edit_User_Admin($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
$content=f_edit_user_admin($Id);
//
$zagcontent=f_zag1(" ");
//
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
//
$objResponse->assign("center5","innerHTML",$content);
// center5
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

f_view_edit_admin, prgus-
ers_admin/function_edit_user_admin.php ( 4.41).
users zakaz. :
;
;
e-mail ;
.

4.41

<?php
//
// $Id - id
function f_edit_user_admin($Id)
{
//
require_once("my.php");
//
require_once("mybaza.php");
4. 393

$text=array();
$text1="";
//
$query1="SELECT * FROM users WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
$row1=mysql_fetch_assoc($rez1);
$text1.="<form id='FormEditUser' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormEditUser\").disabled=true;
xajax.$(\"ButtonFormEditUser\").value=\"...\";
xajax_Go_Edit_User_Admin(xajax.getFormValues(
\"FormEditUser\"));'>";
$text1.="<input type=hidden name='id' value='".$row1[id]."'>";
$text1.="<table>";
$text1.="<tr><td></td><td>".$row1[login]."</td></tr>";
$text1.="<tr><td> (6-12)</td>";
$text1.="<td><input type=text name='password'
value='".$row1[password]."'
size=12 maxlength=12></td></tr>";
$text1.="<tr><td> </td><td>".$row1[data]."</td></tr>";
$arrtype=array("","","User","","","","","","","");
$text1.="<tr><td>
</td><td>".$arrtype[$row1[type]]."</td></tr>";
//
$text1.="<tr><td></td><td><select name='visible'>";
$text1.="<option value='yes' ".(($row1[visible]=='yes')
?('selected'):('')).">yes";
$text1.="<option value='no' ".(($row1[visible]=='no')
?('selected'):('')).">no";
$text1.="<option value='block' ".(($row1[visible]=='block')
?('selected'):('')).">block";
$text1.="</select></td></tr>";
$text1.="<tr><td>E-mail</td>";
$text1.="<td><input type=text name='email' value='".$row1[email]."'
size=30 maxlength=30></td></tr>";
$text1.="<tr><td></td><td>".$row1[vizits]."</td></tr>";
$text1.="<tr><td valign=top>IP-
</td><td>".str_replace(';','<br>',$row1[ip])."</td></tr>";
$text1.="<tr><td></td>";
$text1.="<td><input type=text name='discount'
value='".$row1[discount]."'
size=2 maxlength=2></td></tr>";
$query2="SELECT COUNT(id) FROM zakaz WHERE id_user='".$Id."' ";
$rez2=mysql_query($query2);
$text1.="<tr><td>,
</td><td>".mysql_result($rez2,0)."</td></tr>";
$query3="SELECT COUNT(id) FROM zakaz WHERE id_user='".$Id."' &&
394 II. -

pay='yes' ";
$rez3=mysql_query($query3);
$text1.="<tr><td>
</td><td>".mysql_result($rez3,0)."</td></tr>";
$text1.="</table>";
$text1.="<center><input type='submit' id='ButtonFormEditUser'
value=' ->'>
<br><br><input type='button' value='' onclick='
document.getElementById(\"center5\").innerHTML=\"\";
document.getElementById(\"centercaption5\").innerHTML=
\"\";'></center>";
return $text1;
}
?>

. 4.31.

xajax- Go_Edit_User_Admin,
prgusers_admin/go_edit_user_admin.php ( 4.42).
FormEditUser .

(. 4.32) .

4.42

<?php
//
//
function Go_Edit_User_Admin($Id)
{
4. 395

$objResponse = new xajaxResponse();


$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
//
$query1="UPDATE users SET password='".$Id[password]."',
email='".$Id[email]."',discount='".$Id[discount]."',
visible='".$Id[visible]."' WHERE id='".$Id[id]."' ";
if(mysql_query($query1))
{
$objResponse->alert(" !!!");
$content=f_view_user_admin($Id[id]);
$zagcontent=f_zag1(" ");
}
else
{
$objResponse->alert(" !!!");
$content=f_edit_user_admin($Id[id]);
$zagcontent=f_zag1(" ");
}
$objResponse->assign("centercaption5","innerHTML",$zagcontent);
$objResponse->assign("center5","innerHTML",$content);
$objResponse->script("document.getElementById
('center5').scrollIntoView();");
$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

. 4.32.
396 II. -

4.5.5.
,
. xajax-
Delete_User_Admin, prgusers_admin/delete_user_
admin.php ( 4.43). ID -
users. visile=block. -
(. 4.33).

. 4.33.

4.43

<?php
//
// visible=block
function Delete_User_Admin($Id)
{
$objResponse = new xajaxResponse();
$objResponse->assign("flag_ajax","value",'yes');
//
require_once("mybaza.php");
// users
$query1="UPDATE users SET visible='block' WHERE id='".$Id."' ";
$rez1=mysql_query($query1);
if($rez1)
$objResponse->alert(" !!!");
else
$objResponse->alert(" !!!");
4. 397

$objResponse->assign("flag_ajax","value",'no');
return $objResponse;
}
?>

4.6.
e-mail ICQ
(. 4.34).

. 4.34.

4.6.1. e-mail
my_shop@bk.ru xajax-
Form_Email_Admin, prgcontacts/form_email_admin.php (-
4.44). (div id=windowdop)
e-mail (. 4.35).

my.php: e-mail
EMAILADMIN, ICQ ICQADMIN.

. 4.35. e-mail
398 II. -

4.44

//
function Form_Email_Admin()
{
$objResponse = new xajaxResponse();
require_once("my.php");
require_once("mybaza.php");
//
$objResponse->assign("windowdop","style.display","none");
//
$text1.="<a href='javascript:void(null);' onclick='
document.getElementById(\"windowdop\").style.display=
\"none\";return false;'>
<img src='img/delete.png' align=right></a>";
$text1.="<center><b> <br> e-mail</b><br>";
$text1.="<div id=VhodError></div>";
$text1.="<form id='FormEmailAdmin' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormEmailAdmin\").disabled=true;
xajax.$(\"ButtonFormEmailAdmin\").value=\"...\";
xajax_Go_Email_Admin(xajax.getFormValues(
\"FormEmailAdmin\"));'>";
$text1.="<font color=black> : </font><input
type='hidden' name='toemail' value='".EMAILADMIN."'><br>";
$text1.="<font color=black>(e-mail) : </font><input type='text'
name='fromemail' value=''><br>";
$text1.="<font color=black> : <br></font><input type='text'
name='fromemailtheme' value='' size=40 maxlength=40><br>";
$text1.="<font color=black>:<br></font><textarea
name='fromemailbody' cols=40 rows=7></textarea><br>";
$text1.=" <input id='ButtonFormEmailAdmin' type='submit'
value='>>'>";
$text1.="</center></form>";
//
$objResponse->script("document.getElementById
('windowdop').style.display='block'");
$objResponse->assign("windowdop","innerHTML",$text1);
$objResponse->script("document.getElementById
('windowdop').scrollIntoView();");
return $objResponse;
}
//
function Go_Email_Admin($Id)
{
$objResponse = new xajaxResponse();
4. 399

if(!ereg("^[a-zA-Z0-9]+@[a-zA-Z0-9]+\.([a-z]
{2,4})$",trim($Id[fromemail])))
{
$objResponse->assign("ButtonFormEmailAdmin","disabled",false);
$objResponse->assign("ButtonFormEmailAdmin","value",
">>");
$objResponse->alert(" e-mail !!!");
return $objResponse;
}
if(trim($Id[fromemailtheme])=="")
{
$objResponse->assign("ButtonFormEmailAdmin","disabled",false);
$objResponse->assign("ButtonFormEmailAdmin","value",">>");
$objResponse->alert(" !!!");
return $objResponse;
}
if(trim($Id[fromemailbody])=="")
{
$objResponse->assign("ButtonFormEmailAdmin","disabled",false);
$objResponse->assign("ButtonFormEmailAdmin","value", ">>");
$objResponse->alert(" !!!");
return $objResponse;
}
$headers="From: <".$Id[fromemail].">\n";
$headers.="Subject: ".utftowin($Id[fromemailtheme])."\n";
$headers.="Content-type: text/plain; charset=\"windows-1251\"\n";
if(mail($Id[toemail],utftowin($Id[fromemailtheme]),utftowin(
$Id[fromemailbody]),$headers))
{
$objResponse->assign("windowdop","style.display","none");
$objResponse->alert(" !!!");
}
else
{
$objResponse->assign("ButtonFormEmailAdmin","disabled",false);
$objResponse->assign("ButtonFormEmailAdmin","value",">>");
$objResponse->alert(" !!!");
}
return $objResponse;
}
?>

xajax- Go_Email_Admin,
prgcontacts/form_email_admin.php ( 4.44).
e-mail -
400 II. -

. mail(). -
(. 4.36) ( none -
display id=windowdop).

. 4.36. e-mail

4.6.2. ICQ
385771293 xajax- Form_ICQ_Admin,
prgcontacts/form_icq_admin.php ( 4.45).
(div id=windowdop) -
ICQ (. 4.37).

. 4.37. ICQ

4.45

<?php
// icq
function Form_ICQ_Admin()
4. 401

{
$objResponse = new xajaxResponse();
//
require_once("my.php");
//
require_once("mybaza.php");
// windowdor
$objResponse->assign("windowdop","style.display","none");
//
$text1.="<a href='javascript:void(null);' onclick='
document.getElementById(\"windowdop\").style.display=
\"none\";return false;'>
<img src='img/delete.png' align=right></a>";
$text1.="<center><b> <br>icq</b><br>";
$text1.="<div id=VhodError></div>";
$text1.="<form id='FormICQAdmin' action='javascript:void(null);'
onsubmit='xajax.$(\"ButtonFormICQAdmin\").disabled=true;
xajax.$(\"ButtonFormICQAdmin\").value=\"...\";
xajax_Go_ICQ_Admin(xajax.getFormValues(\"FormICQAdmin\"));
return false; '>";

$text1.="<font color=black> : </font><input


type='hidden' name='toemail' value='".ICQADMIN."'><br>";
$text1.="<font color=black>( ICQ) : </font><input type='text'
name='fromicq' value=''><br>";
$text1.="<font color=black>:<br></font><textarea
name='fromicqbody' cols=40 rows=7></textarea><br>";
$text1.="<input id='ButtonFormICQAdmin' type='submit'
value='>>'>";
$text1.="</center></form>";
// windowdor
$objResponse->script("document.getElementById('windowdop').style.display=
'block'");
//
$objResponse->assign("windowdop","innerHTML",$text1);
// windowdop
$objResponse->script("document.getElementById('windowdop')
.scrollIntoView();");
return $objResponse;
}
// icq
function Go_ICQ_Admin($Id)
{
//
require_once("my.php");
402 II. -

//
require_once("mybaza.php");
$objResponse = new xajaxResponse();
//
if(trim($Id[fromicqbody])=="")
{
$objResponse->assign("ButtonFormICQAdmin","disabled",false);
$objResponse->assign("ButtonFormICQAdmin","value",">>");
$objResponse->alert(" !!!");
return $objResponse;
}
// WebIcqLite
include('WebIcqLite.class.php');
$icq = new WebIcqLite();
// icq
if($icq->connect(ICQ, ICQPASS))
{
//
if(!$icq->send_message(ICQADMIN, $Id[fromicqbody]))
{
//
$objResponse->assign("ButtonFormICQAdmin","disabled",false);
$objResponse->assign("ButtonFormICQAdmin","value",">>");
$objResponse->alert(" icq !".
$icq->error);
}
else
{
// windowdor
$objResponse->assign("windowdop","style.display","none");
$objResponse->alert(" icq!");
}
$icq->disconnect();
}
else
{
$objResponse->assign("ButtonFormICQAdmin","disabled",false);
$objResponse->assign("ButtonFormICQAdmin","value",">>");
$objResponse->alert(" icq !".$icq->error);
}
return $objResponse;
}
?>

xajax- Go_ICQ_Admin,
prgcontacts/form_icq_admin.php ( 4.45), -
4. 403

ICQ .
WebIcqLite ( WebIcqLite.class.php).
(. 4.38) ( -
none display id=windowdop).

. 4.38. ICQ

Web- .

.
AJAX. -

- . -
- , . ,
- . , -
, . ,
. victoruni@km.ru
kmvnews@bk.ru http://goodtovars.ru/blog, -
- AJAX.
, -
.
!

1

CSS


after -
-
, -
. after
-
content:
after { content: "" }
background .
-
background-
attachment .
,
background-color ,
-
background-image . -
background-position , -

background-repeat
background-attachment fixed - background-
- attachment ,
; -
-
scroll . -
-

-

background-color transparent -
; .

<> - - , -

: ,
1) ;

2)
,
#666999;
3) RGB
408


background-image none -
; .

url (' , -
')
,

background-position top
center , -
bottom -
background-image.
left
center : -
right -
.
<> px ,
<> %
background-repeat no-repeat , -
repeat ,
-
repeat-x background-image,
. -
repeat-y

,

before
-
, .
before -

content:
before { content: "" }
border . -
,
border-width
-
border-style .
,
border-color , -
,

border-bottom . -
,
border-bottom-width

border-bottom-style .
,
border-bottom-color , -
,

border-bottom-color <>

1) ;
2)
;
1. CSS 409

3) RGB

border-bottom-style dotted
dashed

solid
double
groove
ridge
inset
outset
border-bottom-width thin (2 ); -

medium (4 );
thick (6 );
<> px
border-collapse collapse - ,
.
; ,

separate - , -

,
-


border-color <>
: . -

1) ;
2)
;
. -
3) RGB , , -
,

border-left . -
,
border-left-width

border-left-style .
,
border-left-color , -
,

border-left-color <> -
:
1) ;
2)
;
410

3) RGB

border-left-style Dotted
dashed

solid
double
groove
ridge
inset
outset
border-left-width thin (2 );

medium (4 );
thick (6 );
<> px
border-right . -
,
border-right-width

border-right-style .
,
border-right-color , -
,

border-right-color <>
:
1) ;
2)
;
3) RGB
border-right-style dotted
dashed

solid
double
groove
ridge
inset
outset
border-right-width thin (2 );

medium (4 );
thick (6 );
<> px
1. CSS 411


border-spacing <> px -
. -
border-spacing -
,

border-collapse -
collapse
border-style dotted -
dashed . -

solid
double
groove
ridge
inset
outset
border-top . -
,
border-top-width

border-top-style .
,
border-top-color , -
,

border-top-color <>

1) ;
2)
;
3) RGB
border-top-style dotted
dashed

solid
double
groove
ridge
inset
outset
border-top-width thin (2 ); -

medium (4 );
thick (6 );
<> px
412


border-width thin (2 ); -

medium (4 );
thick (6 );

<> px
bottom <> px -
<> % -

auto . -
position,

relative ( -
) absolute (-
)
caption-side top - -
, -
;
<CAPTION>
bottom . caption-
- side
; . Firefox
right - -
-
; , -
-
left - CSS
-

clear both - , -
- -

; .

left - float,
- clear
. -



;
right -

;
none -

-
,

float -

1. CSS 413


clip rect(Y1, X1, Y2, X2)
,
auto

. , -
,
-
. -
-
.
-

,

CSS (px) -
(%)
color <> - -
:
1) ;
2)
;
3) RGB
cursor auto ,

; .
url -

,
,
, -
CUR ANI;
default
crosshair
help
move
pointer
progress
text
wait
n-resize
ne-resize
e-resize
se-resize
s-resize
sw-resize
w-resize
nw-resize
414


display block ,
inline , -
inline-block
inline-table
list-item
none
run-in
table
table-caption
table-cell
table-column
table-column-group
table-footer-group
table-header-group
table-row
table-row-group
float left ,
, ,
-
, , -
;
right

,

;
none -

font .
font-family -
font-size .
,
font-style ,
font-weight
font-variant
font-family Geneva
Arial , -

Helvetica .
-
Georgia ,
Times New Roman .
, ,
. Trebuchet MS, -

.
-
,
.
, -


1. CSS 415


font-size <>
xx-small
x-small
small
medium
large
x-large
xx-large
font-style normal - -
; ,
italic -
;
oblique

font-variant normal , -
, -
;
-
small-caps .




font-weight <> (100900)
bold ; 100
900 100
bolder ;
lighter ;
normal

height <> px
(
<> %
, ,
auto <IMG>).
-
,
left <> px -

<> %

auto , ,
,

letter-spacing <> px
-
normal
. -
-
,
, -
.
,

416


line-height normal
<> () ( ) ,
-
<> %
<> px
list-style . -
, -
list-style-image
, ,
list-style-position

list-style-type
list-style-image none -
url(' ') , -

list-style-position outside - , -
-
;
inside -

list-style-type none -
, - . -
;
, -
- list-style-image -
: none
circle
disc
square
-
:
decimal
lower-alpha
lower-roman
upper-alpha
upper-roman
margin auto -
<> px

margin-bottom auto -
<> px

margin-left auto -
<> px

margin-right auto -
<> px

margin-top auto -
<> px
1. CSS 417


max-width <> px
<> %

min-width <> px
<> %

opacity <> (0.01.0) -


Web-.
0 -
-
;
-
1
, -
-

overflow visible - -
- ,
, - -
-
;
hidden

, -
;
scroll -
-
;
auto -


padding <> px
<> % .

-
-
,

padding-bottom <> px
<> %

padding-left <> px
<> %

padding-right <> px
<> %

padding-top <> px
<> %

418


position absolute , -
-
; -
Web-
fixed -
-

absolute,


left, top, right
bottom
-
-
Web-;
relative
-
-
;
static -

quotes ,

:
quotes: " "
" "
right auto -
<> px

<> % , ,
, -

table-layout auto - , -
, -
- ,

-
;
fixed
-

<COL>, -


text-align center
justify -

left
right
1. CSS 419


text-decoration blink
; , -
line-through , -
c .
;
,
overline -
(-
);
underline -

;
none -

text-indent <> px -

<> %
(, <P>).


text-transform capitalize

-
;
lowercase -

( -
);
uppercase -

(
)
top auto -

<> px

<> % , ,
, -

vertical-align baseline -
bottom -
middle
middle
super
text-bottom
text-top
top
visibility visible
,
hidden
.
collapse ,
, ,
, -

420


white-space normal ,

,
-
;
nowrap
HTML -
,

,
, -
<BR>
;
pre -
-
,
-
HTML.


-
,


width auto
<> px (
, ,
<> % <IMG>).
-
,
word-spacing <> px
normal

z-index <>
auto Web- -

, -
-
, -

2

- :
\Denwer_distr -
;
\book_primers xajax
1 2.
;
\magazin (-
).
,
my.php;
\sql ( ) -
(\usr\local\mysql5\data).
: magazin book_examples;
\xajax xajax, 0.5 standard;
\jquery jQuery, 1.4.2 Query UI
JavaScript- jQuery, 1.7.3;
\pspad PSPad Web- -
( , pspad.exe). -

. PSPad (freeware), -
http://www.pspad.com.

A
AJAX 44 61

C
CSS 9 31

D
DHTML 13 :
DOM 14 10
10
H
HTML 7
jQuery:
J append 97
jQuery 92 appendTo 97
attr 97
M css 97
empty 98
MySQL 17 html 98
prepend 97
P prependTo 97
phpMyAdmin 25 text 97
Smarty:
Q assign 131
display 132
Query UI 104 fetch 132
xajaxResponse:
S addEvent 56
Smarty 127 alert 56
append 52
X assign 51
call 56
XAJAX 48 clear 54
xajaxResponse 51 ( . . 424)
424

jQuery ():
create 53
:
createInput 54 Accordion 104
includeScript 55 imageFlow 113
insert 53 jCarousel 101
insertAfter 53 Tabs 105
insertInput 54 :
insertInputAfter 54 a1agregator 190
prepend 52 ONPAY 245
redirect 56 Webmoney 242
remove 53
removeHandler 55

replace 52
script 55 94