示例#1
0
<?php

set_time_limit(0);
function necho($line_number, $string)
{
    echo "{$line_number}: {$string}\n";
    return $string;
}
$errno = 0;
$errstr = "";
$fp = fsockopen('www.google.com', 80, &$errno, &$errstr);
necho(10, $errno);
necho(20, $errstr);
necho(40, fwrite($fp, "GET http://www.google.com/index.html\n"));
necho(50, fflush($fp));
necho(60, fread($fp, 2048));
$errno = 0;
$errstr = "";
$fp = fsockopen('smtp.roadsend.com', 25, &$errno, &$errstr);
necho(70, $errno);
necho(80, $errstr);
necho(100, fwrite($fp, "HELO bob.com\n"));
necho(110, fflush($fp));
necho(120, fread($fp, 80000));
示例#2
0
<?php

function necho($line_number, $string)
{
    echo "{$line_number}: {$string}\n";
    return $string;
}
print ip2long("127.0.0.255") - ip2long("127.0.0.1") . "\n";
// ip2long
necho(420, ip2long('127.0.0.1'));
necho(430, ip2long('192.168.20.40'));
necho(440, ip2long('199.0.0.2'));
necho(450, ip2long('255.255.255.255'));
necho(460, ip2long('0.0.0.0'));
// long2ip
necho(470, long2ip(2130706433));
// 127.0.0.1
necho(480, long2ip(-1062726616));
// 192.168.20.40
necho(490, long2ip(-956301310));
// 199.0.0.2
necho(500, long2ip(-1));
// 255.255.255.255
necho(510, long2ip(0));
// 0.0.0.0
示例#3
0
    necho(950, unlink($symlink_name));
}
// tempnam
$tmpfname = tempnam("/tmp", "cowboy3");
$handle = fopen($tmpfname, "w");
necho(960, fwrite($handle, "writing to tempfile"));
necho(970, fclose($handle));
necho(980, unlink($tmpfname));
// umask
necho(990, umask());
necho(1000, umask(0755));
necho(1010, umask("foo"));
necho(1020, umask());
// touch, unlink
necho(1030, touch($testfile));
necho(1040, file_exists($testfile));
necho(1050, unlink($testfile));
necho(1060, file_exists($testfile));
if (PHP_OS == 'WINNT') {
    echo "1: " . is_dir("c:\\windows") . "\n";
    echo "1a: " . is_dir("c:\\windows\\") . "\n";
    echo "1b: " . is_dir("c:/windows/") . "\n";
    echo "1c: " . is_dir("c:/windows") . "\n";
    echo "2: " . file_exists("./files2.php") . "\n";
    echo "3: " . file_exists("./foobar.php") . "\n";
    echo "4: " . is_file("./foobar2") . "\n";
    echo "5: " . is_file("./foobar") . "\n";
    echo "5a: " . is_readable("./foobar") . "\n";
    echo "6: " . touch("./foobar3") . "\n";
    echo "7: " . unlink("./foobar3") . "\n";
}
示例#4
0
// stream_context_get_options, stream_context_set_options
// stream_context_set_params, stream_get_meta_data
$fp = fopen("/tmp/foobar-context-test-file", "w+");
necho(260, "stream_context_get_options:");
var_dump(stream_context_get_options($fp));
necho(270, stream_context_set_option($fp, "the-wrapper", "the-option", "the-value"));
necho(280, "stream_context_get_options:");
var_dump(stream_context_get_options($fp));
/* XXX get these working. They seem to have implemented in Zend _after_ we did the streams
 * stuff. -Nate
 */
//necho(290, stream_context_set_params($fp, array("param1" => "val1", "param2" => "val2")));
//function callback() { echo "callback called\n"; }
//necho(291, stream_context_set_params($fp, array("notification" => "callback")));
//necho(300, "stream_get_meta_data:");
//var_dump(stream_get_meta_data($fp));
necho(310, "stream_context_get_options:");
var_dump(stream_context_get_options($fp));
necho(320, fclose($fp));
//
// http input
$handle = fopen("http://www.roadsend.com/license/rpl1.txt", 'r');
//it looks like writing it with feof() exposes a bug in Zend.  not 100%
//sure.  but it looks like you have to read from the handle one extra
//time in zend before feof signals an eof.  maybe because the file ends
//with a newline?  dunno.
//while (!feof ($handle)) {
while ($buffer = fgets($handle)) {
    echo "--<{$buffer}>--";
}
fclose($handle);
示例#5
0
    system("tail -5000 `find /var/log -type f` | grep -a {$id} | sed s/..:..:..//g | sed 's/PCC_TEST\\[.*\\]/PCC_TEST/' | sed 's/{$id}/PCC_TEST/' | sort");
}
// define_syslog_variables
necho(410, define_syslog_variables());
//} // winnt
// gethostbynamel
necho(520, gethostbynamel('www.roadsend.com'));
necho(530, gethostbynamel('tenkan.org'));
necho(540, gethostbynamel('localhost'));
// getmxrr
if (PHP_OS != 'WINNT') {
    $mxhosts = array();
    $weights = array();
    necho(550, getmxrr('roadsend.com', &$mxhosts, &$weights));
    sort($mxhosts);
    sort($weights);
    necho(560, "mxhosts: ");
    print_r($mxhosts);
    necho(570, "weights: ");
    print_r($weights);
    necho(580, getmxrr('google.com', &$mxhosts, &$weights));
    sort($mxhosts);
    sort($weights);
    necho(590, "mxhosts: ");
    print_r($mxhosts);
    necho(600, "weights: ");
    print_r($weights);
}
// mail
//mail("*****@*****.**", "Test Subject", "Line 1\nLine 2\nLine 3");
//mail("*****@*****.**", "Test Subject", "Line 1\nLine 2\nLine 3", "From: raven@roadsend.com\r\nReply-To: pym@roadend.com");