get_browser
����������� ������������ ��������.
��������� :
object get_browser([string user_agent]);
������������ ���������� ����������� �� ����� browscap.ini. ��� ����������� �������� ������������ �������� ���������� $HTTP_USER_AGENT ��� ��������, ������������ � ��������� user_agent.
���������� ������������ � ���� ������� ������� � �������� ����������� ����������� �������� (��������, ������, ������������ �� �� javascript ��� cookies).
����������� ������������ ��������.
��������� :
object get_browser([string user_agent]);
������������ ���������� ����������� �� ����� browscap.ini. ��� ����������� �������� ������������ �������� ���������� $HTTP_USER_AGENT ��� ��������, ������������ � ��������� user_agent.
���������� ������������ � ���� ������� ������� � �������� ����������� ����������� �������� (��������, ������, ������������ �� �� javascript ��� cookies).
<?php function list_array($array) { while (list ($key, $val) == each ($array)) { $str .= "<b>$key:</b> $val<br>\n"; } return $str; } echo "$HTTP_USER_AGENT<hr>"; $bouser = get_browser(); echo list_array ((array) $browser); ?>���������� ���������� ������:
Mozilla/4.5 [en] (X11: Linux 2.2.9 i586)<hr> <b>browser_name_pattern:</b>Mozilla/4\.5.*<br> <b>parent:</b>Netscape<br> <b>platform:</b>Unknown<br> <b>majorver:</b>4<br> <b>minorver:</b>5<br> <b>browser:</b>Netscape<br> <b>version:</b>4<br> <b>frames:</b>1<br> <b>tables:</b>1<br> <b>cookies:</b>1<br> <b>backgroundsounds:</b> <br> <b>vbscript:</b> <br> <b>javascript:</b>1<br> <b>javaapplets:</b>1<br> <b>activexcontrols:</b> <br> <b>beta:</b> <br> <b>crawler:</b> <br> <b>authenticodeupdate:</b> <br> <b>msn:</b> <br>��� ���� ����� ������� ����� ���������������, ������� ��������� ������� ����������������� ����� browscan.ini � ����� ������������.
highlight_file
����� ����������� ����� � �������� ���������.
��������� :
boolean highlight_file(string filename);
��� ��� ���� ����� ����������� � ���������. ����� ��������� ���������� ������������ � ����� ������������ PHP. ���������� true ��� false ��� ������.
��������, ����� ��������� ������ Apache ��� ��������� ������� � URL, ����������� �������� ���� "https://���.�������/source/����/�/�����.php", ������� ������� ����� "https://���.�������/source/����/�/�����.php", �������� ���������.�������� � ���� httpd.conf ��������� ��������:
�������� � �������� web-�������� ��������� ���� � ������ source:
����� ����������� ����� � �������� ���������.
��������� :
boolean highlight_file(string filename);
��� ��� ���� ����� ����������� � ���������. ����� ��������� ���������� ������������ � ����� ������������ PHP. ���������� true ��� false ��� ������.
��������, ����� ��������� ������ Apache ��� ��������� ������� � URL, ����������� �������� ���� "https://���.�������/source/����/�/�����.php", ������� ������� ����� "https://���.�������/source/����/�/�����.php", �������� ���������.
# ���������� ��������� "ForceType" ����� �������, # ��� �������� source � URL - �� �������, � ��� �������� PHP <Location /source> ForceType application/x-httpd-php </Location>
<HTML><HEAD> <TITLE>Source Display</TITLE> </HEAD> <BODY bgcolor=#FFEEDD> <?php $script = getenv ("PATH_TRANSLATED"); if(!$script) { echo "<BR><B>ERROR: ������� ��� ��������</B><BR>"; } else { if(ereg("(\.php|\.inc)$",$script)) { echo "<H!>������� �����: $PATH_INFO</H1>\n<hr>\n"; if(!@highlight_file($script)) echo "������ ������ �����"; } else { echo "<H1>ERROR: ������������ ������ �������� PHP ������ </H1>"; } } echo "<HR>�����������: ".date("Y/M/d H:i:s",time()); ?> </BODY> </HTML>
highlight_string
��������� ������ ������.
��������� :
void highlight_string(string str);
������� ��������� ������� highlight_file(), �� ���������� �� ���������� �����, � ��������� ������.
��������� ������ ������.
��������� :
void highlight_string(string str);
������� ��������� ������� highlight_file(), �� ���������� �� ���������� �����, � ��������� ������.
show_source
������� ������� highlight_file.
��������� :
boolean show_source(string str);
������� ������� highlight_file.
��������� :
boolean show_source(string str);
pack
������������� ������ � �������� ������.
��������� :
string pack(string format [,mixed $args, ...]);
������� pack() ����������� �������� ��������� � �������� ������, ������� ����� � ������������. ������ ����������, � ����� �� ����������, �������� ��� ������ ������ $format, ������� ������������ ����� ����� ������������� �������������� �������������� - ��������� ���, ������� ����������� � sprintf(), �� ������ ��� ����� %. ����� ������� ������������� ����� ������ �����, ������� ��������, ������� ���������� ����� ���������� ������ ��������������. � ������, ��� �������� a,A,h � H ����� ������, ����� ���������� �������� ����� �������� � �������� ������ �� ���, ��� ��������� � ��������� ���������-������ ��� ������ ������� (�� ����, ���������� ������ ���� ��� ������ ������). � ������ @ ��� ���������� ���������� �������, � ������� ����� �������� ��������� ������. ��� ���� ��������� �������������� ��������� �� ���� ����� ������ ���������� ����������, �� ������� ���������������� �������� ������� �������. ������ ����� ����� ������� *, � ���� ������ ���������������, ��� ������������ ��������� �� ��� ���������� ������.
��� ������ ������ �������������� �������:
a - ������, ��������� ����� � ���� ����������� �������� � ����� 0;
A - ������, ��������� ����� ����������� ���������;
h - ����������������� ������, ������� ������� � ������;
H - ����������������� ������, ������� ������� � ������;
c - �������� ���� (������);
C - ����������� ����;
s - �������� �������� ����� (16 ������ ������� ������ ������������ ������������ ����������);
S - ����������� �������� �����;
n - ����������� ����� (16 �����, ������� ������� � �����);
v - ����������� ����� (16 �����, ������� ������� � �����);
i - �������� ����� (������ � ������� ������ ������������ ������������);
I - ����������� �����;
l - �������� ������� ����� (32 ����, ������� ������ ������������ ������������);
L - ����������� ������� �����;
N - ����������� ������� ����� (32 ����, ������� ������� � �����);
V - ����������� ����� (32 ����, ������� ������� � �����);
f - ����� � ��������� ������ (������� �� �����������);
d - ����� � ��������� ������ ������� �������� (������� �� �����������);
x - ������ � ������� �����;
X - ������� ����� �� 1 ����;
@ - ���������� ������� ����� �� �������� ���������� �������.
0x12, 0x34, 0x78, 0x56, 0x41, 0x42 (� ����������������� ������� ���������).
������������� ������ � �������� ������.
��������� :
string pack(string format [,mixed $args, ...]);
������� pack() ����������� �������� ��������� � �������� ������, ������� ����� � ������������. ������ ����������, � ����� �� ����������, �������� ��� ������ ������ $format, ������� ������������ ����� ����� ������������� �������������� �������������� - ��������� ���, ������� ����������� � sprintf(), �� ������ ��� ����� %. ����� ������� ������������� ����� ������ �����, ������� ��������, ������� ���������� ����� ���������� ������ ��������������. � ������, ��� �������� a,A,h � H ����� ������, ����� ���������� �������� ����� �������� � �������� ������ �� ���, ��� ��������� � ��������� ���������-������ ��� ������ ������� (�� ����, ���������� ������ ���� ��� ������ ������). � ������ @ ��� ���������� ���������� �������, � ������� ����� �������� ��������� ������. ��� ���� ��������� �������������� ��������� �� ���� ����� ������ ���������� ����������, �� ������� ���������������� �������� ������� �������. ������ ����� ����� ������� *, � ���� ������ ���������������, ��� ������������ ��������� �� ��� ���������� ������.
��� ������ ������ �������������� �������:
// �����, �����, ��� ��������� - ������ $bindata = pack("nvc*", 0x1234, 0x5678, 65, 66);����� ���������� ������������ ���� � ������ $bindata ����� ����������� 6 ������ � ����� ������������������:
0x12, 0x34, 0x78, 0x56, 0x41, 0x42 (� ����������������� ������� ���������).
unpack
������������� ������ �� �������� ������.
��������� :
array unpack(string format, string data);
������������� ������ �� �������� ������ � ������ �������� �������. ���������� ������, ���������� ������������� ��������.
������������� ������ �� �������� ������.
��������� :
array unpack(string format, string data);
������������� ������ �� �������� ������ � ������ �������� �������. ���������� ������, ���������� ������������� ��������.
$array = unpack("c2chars/nint", $binarydata);����������� � ���������� ������ ����� ��������� "chars1", "chars2" � "int".
iptcparse
����������� �������� IPTC ���� �� ��������� ����.
��������� :
array iptcparse(string iptcblock);
��� ������� ����������� �������� ���� IPTC �� ��������� ����. ���������� ������, ������������ tagmarker ��� ������ � �������� ��� ��������. ���������� false ��� ������ ��� ���� ������� IPTC ������ �� ���� �������.
����������� �������� IPTC ���� �� ��������� ����.
��������� :
array iptcparse(string iptcblock);
��� ������� ����������� �������� ���� IPTC �� ��������� ����. ���������� ������, ������������ tagmarker ��� ������ � �������� ��� ��������. ���������� false ��� ������ ��� ���� ������� IPTC ������ �� ���� �������.
leak
�������� ������ ������.
��������� :
void leak(int bytes);
leak() �������� ������������ ����� ������.
��� ������� ��� ������� ���������� ������, ������� ������������� ������� "����������" ������ ��� ���������� �������.
������ ����� ������ ����������� � ������ ���������� bytes.
�������� ������ ������.
��������� :
void leak(int bytes);
leak() �������� ������������ ����� ������.
��� ������� ��� ������� ���������� ������, ������� ������������� ������� "����������" ������ ��� ���������� �������.
������ ����� ������ ����������� � ������ ���������� bytes.
serialize
���������� �������������� ������������� ��������.
��������� :
string serialize(mixed value);
serialize() ���������� ������ ��������� �� ������ ������ ��� ��������������������� value, ������� ����� ���-������ ���������.
��� ������� ��� ���������� ��� �������� �������� PHP ��� ������ �� ���� � ���������.
���������� �������������� ������������� ��������.
��������� :
string serialize(mixed value);
serialize() ���������� ������ ��������� �� ������ ������ ��� ��������������������� value, ������� ����� ���-������ ���������.
��� ������� ��� ���������� ��� �������� �������� PHP ��� ������ �� ���� � ���������.
������ : //$session_data �������� ����������� ������ � ����������� � ������ //�������� ������������. �� ���������� serialize() ��� ���������� //����� � ���� ������ � ����� �������. $conn = odbc_connect("webdb", "php", "chicken"); $stmt = odbc_prepare($conn, "UPDATE sessions SET data = ? WHERE id = ?"); $sqldata = array(serialize($session_data), $PHP_AUTH_USER); if (!odbc_execute($stmt, &$sqldata)) { $stmt = odbc_prepare($conn, INSERT INTO sessions (id, data) VALUES(?, ?)"); if (!odbc_execute($stmt, &$sqldata)) { /* ���-�� ������� �����������. */ } }
unserialize
������� PHP �������� �� ������������ �������������.
��������� :
mixed unserialize(string str);
unserialize() ����� ���� ����������� �������� � ����������� ������� � PHP ��������. ���������� ��������������� ��������, � ����� ����� ���: integer, double, string, array ��� object. ���� ��� ������������ object, �� ������ �� ������������.
������� PHP �������� �� ������������ �������������.
��������� :
mixed unserialize(string str);
unserialize() ����� ���� ����������� �������� � ����������� ������� � PHP ��������. ���������� ��������������� ��������, � ����� ����� ���: integer, double, string, array ��� object. ���� ��� ������������ object, �� ������ �� ������������.
������ : // ����� �� ���������� unserialize() ��� �������� ������ � ������ �� ���� ������ // � $session_data. ���� ������ ��������� ��������� � ����� // � serialize(). $conn = odbc_connect("webdb", "php", "chicken"); $stmt = odbc_prepare($conn, "SELECT data FROM sessions WHERE id = ?"); $sqldata = array($PHP_AUTH_USER); if (!odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) { // ���� ���� ������� ��� ������� , // �� �������������� ������ $session_data = array(); } else { // �� ������ ����� ������������� � $tmp[0]. $session_data = unserialize($tmp[0]); if (!is_array($session_data)) { // ���-�� �����������, �������������� ������ $session_data = array(); } }
uniqid
���������� ���������� �������������.
��������� :
int uniqid(string prefix [, boolean lcg]);
������� uniqid() ���������� ���������� �������������, ���������� �� ������� ������� � ������������� � ������� ������� prefix.
������� ����� ���� �������, ��������, ���� �� ����������� �������������� ������������ �� ��������� ������, �������, ����� �� ���������, ������������ ������������� � ����� � ��� �� ������������. ������� ����� ���� ������ �� 114 ��������.
���� � �������� ��� �������� ���������� ������ ������, �� ����� ���������������� �������������� ����� 13 �������� (��� lcg=true - 23 �������).
���� ������ �������������� �������� lcg �� ��������� true, � ����� �������������� ����� ����������� "��������������� ��� �������� LCG", �������� ��� �������� ����� ����������.
������� ����� �������������� ���������� �������� ������������������ �������� (��������, ��� ����� �������� � ��������������� ������).
���������� ���������� �������������.
��������� :
int uniqid(string prefix [, boolean lcg]);
������� uniqid() ���������� ���������� �������������, ���������� �� ������� ������� � ������������� � ������� ������� prefix.
������� ����� ���� �������, ��������, ���� �� ����������� �������������� ������������ �� ��������� ������, �������, ����� �� ���������, ������������ ������������� � ����� � ��� �� ������������. ������� ����� ���� ������ �� 114 ��������.
���� � �������� ��� �������� ���������� ������ ������, �� ����� ���������������� �������������� ����� 13 �������� (��� lcg=true - 23 �������).
���� ������ �������������� �������� lcg �� ��������� true, � ����� �������������� ����� ����������� "��������������� ��� �������� LCG", �������� ��� �������� ����� ����������.
������� ����� �������������� ���������� �������� ������������������ �������� (��������, ��� ����� �������� � ��������������� ������).
// ��� ��������� ����� $token = md5(uniqid("")); // ��������� $better_token = md5(uniqid(rnad()));��� ������ ���������� 32 ����� (128-������ ����������������� �����): ��� �������� ������������ �������������, ������� ������ ����� �������������.