[code=perl]
sub parse {
my ($self,$raw_cookie) = @_;
my %results;
my(@pairs) = split("; ?",$raw_cookie);
foreach (@pairs) {
s/\s*(.*?)\s*/$1/;
my($key,$value) = split("=");
# Some foreign cookies are not in name=value format, so ignore
# them.
next if !defined($value);
my @values = ();
if ($value ne '') {
@values = map CGI::unescape($_),split(/[&;]/,$value.'&dmy');
pop @values;
}
$key = unescape($key);
# A bug in Netscape can cause several cookies with same name to
# appear. The FIRST one in HTTP_COOKIE is the most recent version.
$results{$key} ||= $self->new(-name=>$key,-value=>\@values);
}
return \%results unless wantarray;
return %results;
}
[/code]
[code=php]
<pre>
<?php
include "classes.inc";
// функции-утилиты
function print_vars($obj)
{
$arr = get_object_vars($obj);
while (list($prop, $val) = each($arr))
echo "\t$prop = $val\n";
}
function print_methods($obj)
{
$arr = get_class_methods(get_class($obj));
foreach ($arr as $method)
echo "\tfunction $method()\n";
}
function class_parentage($obj, $class)
{
if (is_subclass_of($GLOBALS[$obj], $class)) {
echo "Object $obj belongs to class " . get_class($$obj);
echo " a subclass of $class\n";
} else {
echo "Object $obj does not belong to a subclass of $class\n";
}
}
// создание экземпляров объектов
$veggie = new Vegetable(true, "blue");
$leafy = new Spinach();
// распечатка информации об объектах
echo "veggie: CLASS " . get_class($veggie) . "\n";
echo "leafy: CLASS " . get_class($leafy);
echo ", PARENT " . get_parent_class($leafy) . "\n";
[/code]
[code=c]
int FindMax(int n1, int n2)
{
if (n1 > n2)
{
return n1;
}
else
{
return n2;
}
}
void PrintMax(int someNumber)
{
cout << "The max is " << someNumber << endl;
}
void PrintHW()
{
cout << "Hello World" << endl;
}
float FtoC(float faren)
{
float factor = 5./9.;
float freezing = 32.0;
float celsius;
celsius = factor * (faren - freezing);
return celsius;
}
[/code]
[code=sql]
BEGIN
SET NOCOUNT ON
DECLARE @sql varchar(500) --Holds to SQL needed to create columns from error log
IF (SELECT OBJECT_ID(@log_name,'U')) IS NOT NULL
BEGIN
IF @overwrite = 0
BEGIN
RAISERROR('Table already exists. Specify another name or pass 1 to @overwrite parameter',18,1)
RETURN -1
END
ELSE
BEGIN
EXEC('DROP TABLE ' + @log_name)
END
END
--Temp table to hold the output of sp_readerrorlog
CREATE TABLE #errlog
(
err varchar(1000),
controw tinyint
)
--Populating the temp table using sp_readerrorlog
INSERT #errlog
EXEC sp_readerrorlog @log_number
--This will remove the header from the errolog
SET ROWCOUNT 4
DELETE #errlog
SET ROWCOUNT 0
SET @sql = 'SELECT
CONVERT(DATETIME,LEFT(err,23)) [Date],
SUBSTRING(err,24,10) [spid],
RIGHT(err,LEN(err) - 33) [Message],
controw
INTO ' + QUOTENAME(@log_name) +
' FROM #errlog ' +
'WHERE controw = 0'
--Creates the table with the columns Date, spid, message and controw
EXEC (@sql)
--Dropping the temporary table
DROP TABLE #errlog
SET NOCOUNT OFF
PRINT 'Error log successfully imported to table: ' + @log_name
END
[/code]
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Яndex</title>
<link rel="SHORTCUT ICON" href="/favicon.ico">
<base target="_top">
</head>
<body bgcolor="white" text="black" link="999999" vlink="999999" alink="999999"
onLoad="if( self.parent.frames.length != 0 ) self.parent.location = document.location">
<table height="100%" width="100%" border="0">
<tr>
<td align="center">
<form name="web" method="get" action="http://www.yandex.ru/yandsearch">
<input type="hidden" name="rpt" value="rad">
<table border="0" cellspacing="10" cellpadding="0">
<tr>
<td><a href="http://www.yandex.ru/"><img src="logo.gif" alt="Яндекс" width="76" height="44" border="0" /></a></td>
<td><input type="text" name="text" size="50" value="" maxlength="160" /></td>
<td><input type="submit" value="Найти!" /></td>
</tr>
</table>
</form>
<script><!--
document.web.text.focus()
// --></script>
</td>
</tr>
<tr>
[/code]
[code=css]
<style><!--
body,td,div,.p,a{font-family:arial,sans-serif }
div,td{color:#000}
.f,.fl:link{color:#6f6f6f}
a:link,.w,a.w:link,.w a:link{color:#00c}
a:visited,.fl:visited{color:#551a8b}
a:active,.fl:active{color:#f00}
.t a:link,.t a:active,.t a:visited,.t{color:#000}
.t{background-color:#e5ecf9}
.k{background-color:#36c}
.j{width:34em}
.h{color:#36c}
.i,.i:link{color:#a90a08}
.a,.a:link{color:#008000}
.z{display:none}
div.n {margin-top: 1ex}
.n a{font-size:10pt; color:#000}
.n .i{font-size:10pt; font-weight:bold}
.q a:visited,.q a:link,.q a:active,.q {color: #00c; }
.b{font-size: 12pt; color:#00c; font-weight:bold}
.ch{cursor:pointer;cursor:hand}
.e{margin-top: .75em; margin-bottom: .75em}
.g{margin-top: 1em; margin-bottom: 1em}
//-->
</style>
[/code]
[code=javascript]
function ss(w){window.status=w;return true;}
function cs(){window.status='';}
function clk(el,ct,cd) {
if(document.images){
(new Image()).src="/url?sa=T&ct="+escape(ct)+"&cd="+escape(cd)+"&url="+escape(el.href);}
return true;
}
function ga(o,e){if (document.getElementById){
a=o.id.substring(1); p = "";r = "";g = e.target;
if (g) { t = g.id;f = g.parentNode;
if (f) {p = f.id;h = f.parentNode;if (h) r = h.id;}}
else{h = e.srcElement;f = h.parentNode;
if (f) p = f.id;t = h.id;
}
if (t==a || p==a || r==a) return true;
location.href=document.getElementById(a).href}
}
[/code]
http://forum.ru-board.com/topic_c3.cgi?forum=2&topic=1289
sub parse {
my ($self,$raw_cookie) = @_;
my %results;
my(@pairs) = split("; ?",$raw_cookie);
foreach (@pairs) {
s/\s*(.*?)\s*/$1/;
my($key,$value) = split("=");
# Some foreign cookies are not in name=value format, so ignore
# them.
next if !defined($value);
my @values = ();
if ($value ne '') {
@values = map CGI::unescape($_),split(/[&;]/,$value.'&dmy');
pop @values;
}
$key = unescape($key);
# A bug in Netscape can cause several cookies with same name to
# appear. The FIRST one in HTTP_COOKIE is the most recent version.
$results{$key} ||= $self->new(-name=>$key,-value=>\@values);
}
return \%results unless wantarray;
return %results;
}
[/code]
[code=php]
<pre>
<?php
include "classes.inc";
// функции-утилиты
function print_vars($obj)
{
$arr = get_object_vars($obj);
while (list($prop, $val) = each($arr))
echo "\t$prop = $val\n";
}
function print_methods($obj)
{
$arr = get_class_methods(get_class($obj));
foreach ($arr as $method)
echo "\tfunction $method()\n";
}
function class_parentage($obj, $class)
{
if (is_subclass_of($GLOBALS[$obj], $class)) {
echo "Object $obj belongs to class " . get_class($$obj);
echo " a subclass of $class\n";
} else {
echo "Object $obj does not belong to a subclass of $class\n";
}
}
// создание экземпляров объектов
$veggie = new Vegetable(true, "blue");
$leafy = new Spinach();
// распечатка информации об объектах
echo "veggie: CLASS " . get_class($veggie) . "\n";
echo "leafy: CLASS " . get_class($leafy);
echo ", PARENT " . get_parent_class($leafy) . "\n";
[/code]
[code=c]
int FindMax(int n1, int n2)
{
if (n1 > n2)
{
return n1;
}
else
{
return n2;
}
}
void PrintMax(int someNumber)
{
cout << "The max is " << someNumber << endl;
}
void PrintHW()
{
cout << "Hello World" << endl;
}
float FtoC(float faren)
{
float factor = 5./9.;
float freezing = 32.0;
float celsius;
celsius = factor * (faren - freezing);
return celsius;
}
[/code]
[code=sql]
BEGIN
SET NOCOUNT ON
DECLARE @sql varchar(500) --Holds to SQL needed to create columns from error log
IF (SELECT OBJECT_ID(@log_name,'U')) IS NOT NULL
BEGIN
IF @overwrite = 0
BEGIN
RAISERROR('Table already exists. Specify another name or pass 1 to @overwrite parameter',18,1)
RETURN -1
END
ELSE
BEGIN
EXEC('DROP TABLE ' + @log_name)
END
END
--Temp table to hold the output of sp_readerrorlog
CREATE TABLE #errlog
(
err varchar(1000),
controw tinyint
)
--Populating the temp table using sp_readerrorlog
INSERT #errlog
EXEC sp_readerrorlog @log_number
--This will remove the header from the errolog
SET ROWCOUNT 4
DELETE #errlog
SET ROWCOUNT 0
SET @sql = 'SELECT
CONVERT(DATETIME,LEFT(err,23)) [Date],
SUBSTRING(err,24,10) [spid],
RIGHT(err,LEN(err) - 33) [Message],
controw
INTO ' + QUOTENAME(@log_name) +
' FROM #errlog ' +
'WHERE controw = 0'
--Creates the table with the columns Date, spid, message and controw
EXEC (@sql)
--Dropping the temporary table
DROP TABLE #errlog
SET NOCOUNT OFF
PRINT 'Error log successfully imported to table: ' + @log_name
END
[/code]
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Яndex</title>
<link rel="SHORTCUT ICON" href="/favicon.ico">
<base target="_top">
</head>
<body bgcolor="white" text="black" link="999999" vlink="999999" alink="999999"
onLoad="if( self.parent.frames.length != 0 ) self.parent.location = document.location">
<table height="100%" width="100%" border="0">
<tr>
<td align="center">
<form name="web" method="get" action="http://www.yandex.ru/yandsearch">
<input type="hidden" name="rpt" value="rad">
<table border="0" cellspacing="10" cellpadding="0">
<tr>
<td><a href="http://www.yandex.ru/"><img src="logo.gif" alt="Яндекс" width="76" height="44" border="0" /></a></td>
<td><input type="text" name="text" size="50" value="" maxlength="160" /></td>
<td><input type="submit" value="Найти!" /></td>
</tr>
</table>
</form>
<script><!--
document.web.text.focus()
// --></script>
</td>
</tr>
<tr>
[/code]
[code=css]
<style><!--
body,td,div,.p,a{font-family:arial,sans-serif }
div,td{color:#000}
.f,.fl:link{color:#6f6f6f}
a:link,.w,a.w:link,.w a:link{color:#00c}
a:visited,.fl:visited{color:#551a8b}
a:active,.fl:active{color:#f00}
.t a:link,.t a:active,.t a:visited,.t{color:#000}
.t{background-color:#e5ecf9}
.k{background-color:#36c}
.j{width:34em}
.h{color:#36c}
.i,.i:link{color:#a90a08}
.a,.a:link{color:#008000}
.z{display:none}
div.n {margin-top: 1ex}
.n a{font-size:10pt; color:#000}
.n .i{font-size:10pt; font-weight:bold}
.q a:visited,.q a:link,.q a:active,.q {color: #00c; }
.b{font-size: 12pt; color:#00c; font-weight:bold}
.ch{cursor:pointer;cursor:hand}
.e{margin-top: .75em; margin-bottom: .75em}
.g{margin-top: 1em; margin-bottom: 1em}
//-->
</style>
[/code]
[code=javascript]
function ss(w){window.status=w;return true;}
function cs(){window.status='';}
function clk(el,ct,cd) {
if(document.images){
(new Image()).src="/url?sa=T&ct="+escape(ct)+"&cd="+escape(cd)+"&url="+escape(el.href);}
return true;
}
function ga(o,e){if (document.getElementById){
a=o.id.substring(1); p = "";r = "";g = e.target;
if (g) { t = g.id;f = g.parentNode;
if (f) {p = f.id;h = f.parentNode;if (h) r = h.id;}}
else{h = e.srcElement;f = h.parentNode;
if (f) p = f.id;t = h.id;
}
if (t==a || p==a || r==a) return true;
location.href=document.getElementById(a).href}
}
[/code]
http://forum.ru-board.com/topic_c3.cgi?forum=2&topic=1289