<?php

// $CVSHeader: _freebeer/www/demo/HTML.LockFormFields.php,v 1.3 2004/03/08 04:29:18 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
// \todo fix wget's continuously reporting "End of file while parsing headers."
if (preg_match('/wget/i', $_SERVER['HTTP_USER_AGENT'])) {
    echo "<html><body></body></html>";
    exit(0);
}
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/HTML/LockFormFields.php';
echo html_header_demo('fbHTML_LockFormFields Class (Lock Selected Form Fields)');
$msg = 'Values in v1 and v2 are locked. Values in v3 and v4 can be modified.';
$locked_fields = array('textfield1', 'textfield2');
if (isset($_REQUEST['set'])) {
    $_REQUEST = fbHTML_LockFormFields::set($_REQUEST, $locked_fields);
} elseif (isset($_REQUEST['check'])) {
    if (fbHTML_LockFormFields::check($_REQUEST, $locked_fields)) {
        $msg = 'Values in v1 and v2 have not been modified.<br>';
    } else {
        $msg = '<b>WARNING: v1 and/or v2 have been modified.</b><br>';
    }
    //	$msg .= 'hash=' . fbHTML_LockFormFields::_generateHash($_REQUEST, $locked_fields);
    //	$msg .= "<br />\n";
} else {
    $_REQUEST['textfield1'] = 'Value1';
    $_REQUEST['textfield2'] = 'Value2';
    $_REQUEST['textfield3'] = 'Value3';
    $_REQUEST['textfield4'] = 'Value4';
}
Exemple #2
0
<?php

// $CVSHeader: _freebeer/www/demo/Backport.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/Backport.php';
echo html_header_demo('fbBackport.php Demo');
echo "<pre>\n";
$a = array('green', 'red', 'yellow');
$b = array('avocado', 'apple', 'banana');
$rv = array_combine($a, $b);
print_r($rv);
//		$rv = array('green' => 'avocado', 'red' => 'apple', 'yellow' => 'banana');
$expected = array('green' => 'avocado', 'red' => 'apple', 'yellow' => 'banana');
assert($expected == $rv);
$a1 = array('a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red');
$a2 = array('a' => 'green', 'yellow', 'red');
$result = array_diff_assoc($a1, $a2);
echo 'array_diff_assoc($a1, $a2)=';
print_r($result);
$expected = array('b' => 'brown', 'c' => 'blue', '0' => 'red');
echo $result == $expected ? 'ok' : '*FAILED*';
echo "\n\n";
$result = sha1('A');
echo 'sha1(A)=', $result, "\n";
$expected = '6dcd4ce23d88e2ee9568ba546c007c63d9131c1b';
echo $result == $expected ? 'ok' : '*FAILED*';
echo "\n\n";
printf("sha1_file(%s)=", basename(__FILE__));
echo sha1_file(__FILE__);
Exemple #3
0
<?php

// $CVSHeader: _freebeer/www/demo/setlocale.php,v 1.2 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/Locale.php';
require_once FREEBEER_BASE . '/lib/ISO639.php';
require_once FREEBEER_BASE . '/lib/ISO639/Alpha3.php';
require_once FREEBEER_BASE . '/lib/ISO639/Map.php';
require_once FREEBEER_BASE . '/lib/ISO3166.php';
require_once FREEBEER_BASE . '/lib/ISO639/ISO3166_Map.php';
require_once FREEBEER_BASE . '/lib/ISO3166/ISO639_Map.php';
echo html_header_demo('fbLocale Class');
// en_US.iso885915
/*
$h = fbISO3166::getIDToNameHash();

$cc2lang = fbISO639_ISO3166_Map::getCountryIDToLanguageIDHash();

$cc2lang = array_flip($cc2lang);

echo "<pre>\n";

foreach ($h as $country_id => $country_name) {
	$lang = @$cc2lang[$country_id];
	printf("\t\t'%s'\t=> '%s',\t// '%s'\t=> '%s'\n", 
		$country_id, 
		$lang, 
		$country_name,
		fbISO639::getLanguageName($lang)
Exemple #4
0
<?php

// $CVSHeader: _freebeer/www/demo/hmac_login/server_adodb.php,v 1.3 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once '../_demo.php';
$title = 'fbHMAC_Login_ADOdb Class (Secure Challenge/Response Login)';
require_once FREEBEER_BASE . '/lib/HMAC_Login/ADOdb.php';
$html_header = html_header_demo($title, null, null, false);
require_once FREEBEER_BASE . '/lib/HTTP.php';
$client_url = dirname(dirname($_SERVER['PHP_SELF'])) . '/Hmac_Login.ADOdb.php';
if (!isset($_REQUEST['challenge'])) {
    fbHTTP::redirect($client_url);
    exit;
}
echo $html_header;
$hmac_login =& new fbHMAC_Login_ADOdb();
$hmac_login->setTimeout(10);
if (!$hmac_login->connect('localhost', 'root', '', 'hmac_login', 'mysql')) {
    echo $hmac_login->getLastError();
    exit;
}
// $hmac_login->_dbh->debug = true;
$hmac_login->validate(@$_REQUEST['challenge'], @$_REQUEST['response'], @$_REQUEST['login'], @$_REQUEST['password']);
echo $hmac_login->getLastError();
?>

<p>
<a href="<?php 
echo $client_url;
?>
<?php

// $CVSHeader: _freebeer/www/demo/Binary_Search.File.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/BinarySearch/File.php';
echo html_header_demo('fbBinarySearch_File Class (Binary Search a Sorted, Fixed Length Record File)');
@ini_set('max_execution_time', 0);
echo "<pre>\n";
$file = FREEBEER_BASE . '/etc/geo/geo-ips.txt';
$ips = array('0.0.0.0' => '000.000.000.000 000.255.255.255 US', '10.0.0.1' => '010.000.000.000 010.255.255.255 I0', '10.255.255.255' => '010.000.000.000 010.255.255.255 I0', '127.0.0.1' => '127.000.000.000 127.255.255.255 L0', '127.0.0.2' => '127.000.000.000 127.255.255.255 L0', '127.255.255.255' => '127.000.000.000 127.255.255.255 L0', '172.16.0.0' => '172.016.000.000 172.031.255.255 I0', '172.31.255.255' => '172.016.000.000 172.031.255.255 I0', '192.168.0.0' => '192.168.000.000 192.168.255.255 I0', '192.168.0.1' => '192.168.000.000 192.168.255.255 I0', '192.168.255.255' => '192.168.000.000 192.168.255.255 I0', '217.194.16.0' => '217.194.016.000 217.194.031.255 EU', '217.194.16.1' => '217.194.016.000 217.194.031.255 EU', '255.0.0.0' => '221.097.211.000 255.255.255.255 US', '255.255.255.254' => '221.097.211.000 255.255.255.255 US', '255.255.255.255' => '255.255.255.255 255.255.255.255 --', '9.20.0.0' => '009.020.000.000 009.020.127.255 GB');
function _formatIP4address($ip, $format = '%03d.%03d.%03d.%03d')
{
    $l = ip2long($ip);
    if ($l == -1 && $ip != '255.255.255.255') {
        return false;
    }
    $tuple1 = $l >> 24;
    if ($tuple1 < 0) {
        $tuple1 += 256;
    }
    $rv = sprintf($format, $tuple1, $l >> 16 & 0xff, $l >> 8 & 0xff, $l & 0xff);
    //printf("l=%s ip=%s rv=%s\n", $l, $ip, $rv);
    return $rv;
}
foreach ($ips as $ip => $expected_result) {
    $ipf = _formatIP4address($ip);
    $bsf =& new fbBinarySearch_File($file);
    $found = $bsf->search($ipf);
    $found = trim($found);
Exemple #6
0
<?php

// $CVSHeader: _freebeer/www/demo/Hmac_Login.MySQL.php,v 1.3 2004/03/08 04:29:18 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
$title = 'fbHMAC_Login_MySQL Class (Secure Challenge/Response Login)';
require_once FREEBEER_BASE . '/lib/ErrorHandler.php';
require_once FREEBEER_BASE . '/lib/HMAC_Login/MySQL.php';
fbErrorHandler::init();
echo html_header_demo($title, null, array('../opt/pajhome.org.uk/md5.js', '../lib/StrUtils.js'));
$hmac_login =& new fbHMAC_Login_MySQL();
/// \todo add as fields on from with a connect button
if (!$hmac_login->connect('localhost', 'root', '', 'hmac_login')) {
    echo $hmac_login->getLastError();
    exit;
}
// $hmac_login->_dbh->debug = true;
$challenge = $hmac_login->getChallenge();
if (!$challenge) {
    echo $hmac_login->getLastError();
    exit;
}
$hchallenge = htmlspecialchars($challenge);
?>
<script type="text/javascript" language="JavaScript" src="../opt/pajhome.org.uk/md5.js"></script>
<script type="text/javascript" language="JavaScript" src="../lib/StrUtils.js"></script>
<script type="text/javascript" language="JavaScript">
<!-- // <![CDATA[
function form_onsubmit(f) {
	f['login'].value	= StrUtils.trim(f['login'].value);
Exemple #7
0
<?php

// $CVSHeader: _freebeer/www/demo/HTTP.ServerPush.php,v 1.3 2004/03/08 04:29:18 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
// \todo fix wget's continuously reporting "End of file while parsing headers."
if (preg_match('/wget/i', $_SERVER['HTTP_USER_AGENT'])) {
    echo "<html><body></body></html>";
    exit(0);
}
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/HTTP/ServerPush.php';
$html_header = html_header_demo('fbHTTP_ServerPush Class');
function page_function($push_mode, $seconds = null, $url = null, $loop = 0)
{
    $rv = '';
    if ($push_mode == FB_HTTP_SERVER_PUSH) {
        $rv .= "Content-type: text/html\n\n";
    }
    global $html_header;
    $spaces = '';
    #str_repeat('IESUCKS!', 10000);
    $time = strftime('%c');
    $refresh_method = $push_mode == FB_HTTP_SERVER_PUSH ? 'server push method' : 'HTTP Refresh command';
    $a = $_SERVER;
    ksort($a);
    $s = var_export($a, true);
    $rv .= $html_header;
    $CVSHeader = '$CVSHeader: _freebeer/www/demo/HTTP.ServerPush.php,v 1.3 2004/03/08 04:29:18 ross Exp $';
    $rv .= "The time is {$time}\n<br />\n<br />\n<i>Refresh <!-- {$loop} of {$_REQUEST['loops']} --> every {$_REQUEST['seconds']} seconds using {$refresh_method}</i>\n<pre>\n<form>\nSeconds: <input type='text' name='seconds' value='{$_REQUEST['seconds']}' />\n<!-- \nLoops:   <input type='text' name='loops' value='{$_REQUEST['loops']}' />\n-->\n<input type='submit' value='Submit' />\n</form>\n{$s}<!-- {$spaces} --></pre>\nSee\n<br />\n<a target='_blank' href='http://wp.netscape.com/assist/net_sites/pushpull.html'>An Exploration of Dynamic Documents</a>\n</p>\n\n<address>\n{$CVSHeader}\n</address>\n</body>\n</html>\n";
    return $rv;
Exemple #8
0
<?php

// $CVSHeader: _freebeer/www/demo/HTTP.PathInfo(1).php,v 1.3 2004/03/08 04:29:18 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
// \todo fix wget's continuously reporting "End of file while parsing headers."
if (preg_match('/wget/i', $_SERVER['HTTP_USER_AGENT'])) {
    echo "<html><body></body></html>";
    exit(0);
}
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/HTTP/PathInfo.php';
fbHTTP_PathInfo::redirect();
session_start();
echo html_header_demo('HTTP/PathInfo class tester', null, null, false);
$url = $_SERVER['SCRIPT_NAME'];
echo "<a href=\"{$url}\">{$url}</a><br />\n";
$url = $_SERVER['REQUEST_URI'];
if (!isset($_SERVER['PATH_INFO'])) {
    $url .= '/PATH_INFO';
}
echo "<a href=\"{$url}\">{$url}</a><br />\n";
$url = $_SERVER['REQUEST_URI'];
if (!isset($_SERVER['PATH_INFO'])) {
    $url .= '/param1/value1/param2/value2';
}
echo "<a href=\"{$url}\">{$url}</a><br />\n";
echo "<a href=\"get.php\">get.php</a><br />\n";
echo "<pre>";
if (isset($_SESSION)) {
    echo '$_SESSION=';
Exemple #9
0
//$https->setHttpsPath('');
if (!empty($_REQUEST['http'])) {
    $https->httpMe();
} elseif (!empty($_REQUEST['https'])) {
    $https->httpsMe();
    $https->httpLinkify();
} elseif (!empty($_REQUEST['https_input'])) {
    $https->httpsMe();
    $https->httpLinkify(true);
}
session_start();
if (isset($_SERVER['HTTP_REFERER']) && !isset($_SESSION['fbHTTPS']['HTTP_REFERER'])) {
    $_SESSION['fbHTTPS']['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'];
}
$path = isset($_SESSION['fbHTTPS']['HTTP_REFERER']) ? $_SESSION['fbHTTPS']['HTTP_REFERER'] : '';
echo html_header_demo($title, $path);
echo $https->isHttps() ? 'Secure (HTTPS)' : 'Not secure (HTTP)';
echo '<br />';
$h = $_SERVER['HTTP_HOST'];
$a_hrefs = array();
$delims = array('', '\'', '"');
$urls = array($_SERVER['PHP_SELF'], basename($_SERVER['PHP_SELF']), dirname($_SERVER['PHP_SELF']), dirname($_SERVER['PHP_SELF']) . '/', '.', '/', '');
$hosts = array("", "http://{$h}", "https://{$h}", "http://{$h}:80", "https://{$h}:443");
$a_hrefs = array();
foreach ($hosts as $host) {
    foreach ($urls as $url) {
        foreach ($delims as $delim) {
            if ($host && substr($url, 0, 1) != '/') {
                continue;
            }
            $a_hrefs[] = '<a href=' . $delim . $host . $url . $delim . '>';
Exemple #10
0
<?php

// $CVSHeader: _freebeer/www/demo/lib.bin2hex.php,v 1.2 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
echo html_header_demo('JavaScript Bin2Hex Class', '../lib/bin2hex.js');
if (!isset($_REQUEST['t_input'])) {
    $_REQUEST['t_input'] = 'enter text to bin2hex here';
}
if (!isset($_REQUEST['t_bin2hex'])) {
    $_REQUEST['t_bin2hex'] = '';
}
if (!isset($_REQUEST['t_hex2bin'])) {
    $_REQUEST['t_hex2bin'] = '';
}
?>
<script type="text/javascript" language="javascript1.2" src="../lib/bin2hex.js">
</script>
<script type="text/javascript" language="javascript1.2">
<!-- // <![CDATA[
function btn_bin2hex_onclick(f) {
	f.t_bin2hex.value = bin2hex(f.t_input.value);
	f.t_hex2bin.value = hex2bin(f.t_bin2hex.value);
	return false;
}
// ]]> -->
</script>

<form method="post" name='frm_bin2hex'>
<table>
Exemple #11
0
<?php

// $CVSHeader: _freebeer/www/demo/Mhash.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/Mhash.php';
echo html_header_demo('fbMhash Class (mhash() Emulation)');
$data = 'data';
$key = 'key';
echo "<pre>\n";
echo "mhash(MHASH_MD5, '{$data}', '{$key}')=", mhash(MHASH_MD5, $data, $key), "\n";
echo "bin2hex(mhash(MHASH_MD5, '{$data}', '{$key}'))=   ", bin2hex(mhash(MHASH_MD5, $data, $key)), "\n";
if (class_exists('fbMhash')) {
    echo "fbMhash::mhashhex(MHASH_MD5, '{$data}', '{$key}')=", fbMhash::mhashhex(MHASH_MD5, $data, $key), "\n";
}
if (defined('MHASH_SHA1')) {
    echo "mhash(MHASH_SHA1, '{$data}', '{$key}')=", mhash(MHASH_SHA1, $data, $key), "\n";
    echo "bin2hex(mhash(MHASH_SHA1, '{$data}', '{$key}'))=   ", bin2hex(mhash(MHASH_SHA1, $data, $key)), "\n";
    if (class_exists('fbMhash')) {
        echo "fbMhash::mhashhex(MHASH_SHA1, '{$data}', '{$key}')=", fbMhash::mhashhex(MHASH_SHA1, $data, $key), "\n";
    }
}
$hash_map = array(0 => 'MHASH_CRC32', 9 => 'MHASH_CRC32B', 8 => 'MHASH_GOST', 13 => 'MHASH_HAVAL128', 12 => 'MHASH_HAVAL160', 11 => 'MHASH_HAVAL192', 10 => 'MHASH_HAVAL224', 3 => 'MHASH_HAVAL256', 16 => 'MHASH_MD4', 1 => 'MHASH_MD5', 5 => 'MHASH_RIPEMD160', 2 => 'MHASH_SHA1', 17 => 'MHASH_SHA256', 7 => 'MHASH_TIGER', 14 => 'MHASH_TIGER128', 15 => 'MHASH_TIGER160');
$nr = mhash_count();
for ($i = 0; $i < $nr; $i++) {
    echo sprintf("The blocksize of %s is %d\n", mhash_get_hash_name($i), mhash_get_block_size($i));
}
?>
</pre>
<address>
Exemple #12
0
<?php

// $CVSHeader: _freebeer/www/demo/lib.qsort.php,v 1.2 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
echo html_header_demo('JavaScript QSort Class', '../lib/qsort.js');
?>
<script type="text/javascript" language="JavaScript" src="../lib/qsort.js"></script>

<script type="text/javascript" language="JavaScript">
<!-- // <![CDATA[
var x = new Array();
for (var i = 0; i <= 10; ++i) {
	x[i] = Math.floor(65535 * Math.random());
}

document.write('Unsorted: ');

document.write(x.toString());

document.write('<br />Sorted:   ');

qsort(x); // , 0, x.length - 1);

document.write(x.toString());

//document.write('\nlength=' + x.length + "<br />\n");
// ]]> -->
</script>
Exemple #13
0
<?php

// $CVSHeader: _freebeer/www/demo/Debug.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/Debug.php';
fbDebug::setLevel(FB_DEBUG_ALL);
echo html_header_demo('fbDebug demo');
echo "<pre>\n";
echo 'fbDebug::getLevel()=', fbDebug::getLevel(), "\n";
fbDebug::log('log');
assert('1 == 2');
print_r(debug_backtrace());
fbDebug::stackdump();
fbDebug::trace("Hey you!");
?>
</pre>
<address>
$CVSHeader: _freebeer/www/demo/Debug.php,v 1.2 2004/03/07 17:51:33 ross Exp $
</address>

</body>
</html>
Exemple #14
0
<?php

// $CVSHeader: _freebeer/www/demo/lib.jsrpc.php,v 1.2 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
echo html_header_demo('JavaScript RPC (Remote Procedure Call)', './jsrpc/jsrpc2.php');
// \todo classify this logic
?>

<script type="text/javascript" language="JavaScript">
<!-- // <![CDATA[
function serverGetTime() {
  var iframe = document.getElementById("COMM");
  if (!iframe) {
    return true;
  }
  var answ = document.getElementById("ANSW");
  if (!answ) {
    return true;
  }
  iframe.src = "jsrpc/jsrpc2.php";
  return false;
}

function handleServerResponse(message) {
  var answ = document.getElementById("ANSW");
  if (answ) {
    answ.innerHTML = 'jsrpc2.php returned "' + message + '"';
  }
  var iframe = document.getElementById("COMM");
Exemple #15
0
<?php

// $CVSHeader: _freebeer/www/demo/lib.base64.php,v 1.2 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
echo html_header_demo('JavaScript Base64 Class', '../lib/Base64.js');
if (!isset($_REQUEST['t_input'])) {
    $_REQUEST['t_input'] = 'enter text to base64 encode here';
}
if (!isset($_REQUEST['t_base64encode'])) {
    $_REQUEST['t_base64encode'] = '';
}
if (!isset($_REQUEST['t_base64decode'])) {
    $_REQUEST['t_base64decode'] = '';
}
?>
<script type="text/javascript" language="javascript1.2" src="../lib/Base64.js">
</script>
<script type="text/javascript" language="javascript1.2">
<!-- // <![CDATA[
function btn_base64_onclick(f) {
	f.t_base64encode.value = Base64.encode(f.t_input.value);
	f.t_base64decode.value = Base64.decode(f.t_base64encode.value);
	return false;
}

// ]]> -->
</script>

<form method="post" name='frm_base64'>
Exemple #16
0
<?php

// $CVSHeader: _freebeer/www/demo/index.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
echo html_header_demo();
$www_dir = dirname($_SERVER['SCRIPT_NAME']);
$dh = opendir(dirname(__FILE__));
// /todo fixme
$files = array();
while ($file = readdir($dh)) {
    if (!preg_match('/\\.php$/', $file) || preg_match('/^index\\.php$/', $file) || preg_match('/^_.*\\.php$/', $file)) {
        continue;
    }
    $files[] = $file;
}
closedir($dh);
sort($files);
$body_text = '';
foreach ($files as $file) {
    $body_text .= sprintf("<a href=\"%s\">%s</a><br />\n", $www_dir . '/' . $file, $file);
}
echo $body_text;
?>
<address>
$CVSHeader: _freebeer/www/demo/index.php,v 1.2 2004/03/07 17:51:33 ross Exp $
</address>
</body>
</html>
Exemple #17
0
<?php

// $CVSHeader: _freebeer/www/demo/HTML.Calender.php,v 1.3 2004/03/08 04:29:18 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
// \todo fix wget's continuously reporting "End of file while parsing headers."
if (preg_match('/wget/i', $_SERVER['HTTP_USER_AGENT'])) {
    echo "<html><body></body></html>";
    exit(0);
}
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/Pear/Pear.php';
require_once FREEBEER_BASE . '/lib/HTML/Calendar.php';
require_once 'HTML/Form.php';
echo html_header_demo('fbHTML_Calendar Class');
if (preg_match('/wget/i', $_SERVER['HTTP_USER_AGENT'])) {
    echo "</body></html>";
    exit(0);
}
class MyHTML_Calendar extends fbHTML_Calendar
{
    function drawCellText($days, $week, $col)
    {
        $rv = '';
        $len = rand(0, 16);
        while (strlen($rv) < $len) {
            $rv .= substr(md5(rand()), 1, rand(1, 8)) . " ";
        }
        return $rv;
    }
}
<?php

// $CVSHeader: _freebeer/www/demo/ADOdb.adodb-session.php,v 1.4 2004/03/08 04:29:18 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/ADOdb/ADOdb.php';
require_once FREEBEER_BASE . '/opt/adodb/session/adodb-session.php';
$html_header = html_header_demo('ADODB_Session Class');
// to test the emulation code:
// require_once 'adodb/adodb-session-clob.php';
// require_once 'adodb/adodb-cryptsession.php';
// ADODB_Session::data_field_name('session_data');
// to test the original code:
// require_once ADODB_DIR . '/adodb-session.php';
// require_once ADODB_DIR . '/adodb-session-clob.php';
// require_once ADODB_DIR . '/adodb-cryptsession.php';
$gzip = (int) fbHTTP::getRequestVar('gzip');
$bzip2 = (int) fbHTTP::getRequestVar('bzip2');
$md5 = (int) fbHTTP::getRequestVar('md5');
$mcrypt = (int) fbHTTP::getRequestVar('mcrypt');
$secret = (int) fbHTTP::getRequestVar('secret');
$filters = array();
if ($gzip) {
    if (include_once ADODB_DIR . '/session/adodb-compress-gzip.php') {
        $filters[] =& new ADODB_Compress_Gzip();
    }
}
if ($bzip2) {
    if (include_once ADODB_DIR . '/session/adodb-compress-bzip2.php') {
        $filters[] =& new ADODB_Compress_Bzip2();
Exemple #19
0
<?php

// $CVSHeader: _freebeer/www/demo/lib.arcfour.php,v 1.2 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
// See doc/license.txt or http://freebeer.sf.net/license.txt for details.
require_once './_demo.php';
echo html_header_demo('JavaScript Arcfour/MD5/SHA-1 Encryption', '../opt/vidwest.com/arcfour.js');
?>

<script type="text/javascript" language="javascript1.3" src="/opt/vidwest.com/arcfour.js">
</script>
<noscript>Sorry, this program needs a JavaScript 1.3 enabled browser!</noscript>

<script type="text/javascript" language="JavaScript">
<!-- // <![CDATA[
/* top-level functions  - testing... */
function initialize() {
	MD5test(1);
	SHA1test(1);
}

function digest(f) {
	if (f.h[0].checked) {
		f.k.value = MD5(f.t.value);
	} else {
		f.k.value = SHA1(f.t.value);
	}
}
function encrypt(f) {
	var key = f.k.value.substring(0,8);
<?php

// $CVSHeader: _freebeer/www/demo/Binary_Search.Array.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/BinarySearch/Array.php';
echo html_header_demo('fbBinarySearch_Array Class (Binary Search an Array)');
echo "<pre>";
if (!isset($_REQUEST['elements'])) {
    $_REQUEST['elements'] = 10;
}
if (!isset($_REQUEST['attempts'])) {
    $_REQUEST['attempts'] = 10;
}
$elements = $_REQUEST['elements'];
$attempts = $_REQUEST['attempts'];
$a = array();
for ($i = 0; $i < $elements; ++$i) {
    $a[$i] = sprintf('%010.10d', mt_rand() % 2000000000);
}
sort($a);
// echo 'a=';	print_r($a);
function compare($a, $b)
{
    if ($a > $b) {
        return 1;
    }
    if ($a < $b) {
        return -1;
    }
Exemple #21
0
<?php

// $CVSHeader: _freebeer/www/demo/phpinfo.php,v 1.2 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
echo html_header_demo('phpinfo()');
if (preg_match('/wget/i', $_SERVER['HTTP_USER_AGENT'])) {
    echo "</body></html>";
    exit(0);
}
$infos = array(INFO_GENERAL => 'INFO_GENERAL', INFO_CREDITS => 'INFO_CREDITS', INFO_CONFIGURATION => 'INFO_CONFIGURATION', INFO_MODULES => 'INFO_MODULES', INFO_ENVIRONMENT => 'INFO_ENVIRONMENT', INFO_VARIABLES => 'INFO_VARIABLES', INFO_LICENSE => 'INFO_LICENSE', INFO_ALL => 'INFO_ALL');
if (!isset($_REQUEST['info'])) {
    $_REQUEST['info'] = INFO_ALL;
}
foreach ($infos as $key => $value) {
    $url = $_SERVER['PHP_SELF'] . '?info=' . $key;
    printf("<a href=\"%s\">%s</a><br />\n", $url, $value);
}
phpinfo($_REQUEST['info']);
?>

<br />

<address>
$CVSHeader: _freebeer/www/demo/phpinfo.php,v 1.2 2004/03/07 17:51:34 ross Exp $
</address>

</body>
</html>
Exemple #22
0
<?php

// $CVSHeader: _freebeer/www/demo/GeoIP.Free.Ascii.php,v 1.3 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/GeoIP/Free/Ascii.php';
echo html_header_demo('fbGeoIP_Free_Ascii Class');
echo "<pre>\n";
$ips = array('0.0.0.0', '10.0.0.1', '10.255.255.255', '127.0.0.1', '127.0.0.2', '127.255.255.255', '127.255.255.255', '172.16.0.0', '172.31.255.255', '192.168.0.0', '192.168.0.1', '192.168.255.255', '217.194.16.0', '217.194.16.1', '255.0.0.0', '255.255.255.254', '255.255.255.255', '9.20.0.0');
foreach ($ips as $ip) {
    $rv = fbGeoIP_Free_Ascii::getCountryIDByIP($ip);
    printf("%-20s: '%s'\n", $ip, $rv);
}
echo "\n";
flush();
$hosts = array('localhost', 'sf.net');
foreach ($hosts as $host) {
    $rv = fbGeoIP_Free_Ascii::getCountryIDByHostName($host);
    printf("%-20s: '%s'\n", $host, $rv);
}
?>
<address>
$CVSHeader: _freebeer/www/demo/GeoIP.Free.Ascii.php,v 1.3 2004/03/07 17:51:33 ross Exp $
</address>

</body>
</html>
Exemple #23
0
<?php

// $CVSHeader: _freebeer/www/demo/Gettext(2).php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/Gettext.php';
echo html_header_demo('fbGettext Class (gettext() Emulation)');
echo "<pre>\n";
bindtextdomain('freebeer', FREEBEER_BASE . '/lib/locale');
textdomain('freebeer');
$iso_codes = array('it_IT' => 'Italian', 'fr_FR' => 'French', 'es_ES' => 'Spanish', 'nl_NL' => 'Dutch', 'en_US' => 'English', 'pt_PT' => 'Portuguese');
foreach ($iso_codes as $iso_code => $language) {
    // \todo convert to one function!
    putenv('LANG=' . $iso_code);
    if (preg_match('/^win/i', PHP_OS)) {
        $rv = setlocale(LC_ALL, $language);
    } else {
        $rv = setlocale(LC_ALL, $iso_code);
    }
    printf("%-12s: %s\n", $language, _("24 hours"));
}
?>
</pre>
<address>
$CVSHeader: _freebeer/www/demo/Gettext(2).php,v 1.2 2004/03/07 17:51:33 ross Exp $
</address>

</body>
</html>
Exemple #24
0
<?php

// $CVSHeader: _freebeer/www/demo/headers.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
$html_header = html_header_demo('HTTP Cache Headers tester', null, null, false);
if (preg_match('/wget/i', $_SERVER['HTTP_USER_AGENT'])) {
    echo "</body></html>";
    exit(0);
}
$headers = array('Expires: Thu, 01 Jan 1970 00:00:00 GMT', 'Last-Modified: Tue, 19 Jan 2038 03:14:07 GMT', 'Cache-Control: no-store, no-cache, must-revalidate', 'Cache-Control: post-check=0, pre-check=0', 'Pragma: no-cache');
$submit_headers = array();
//$_REQUEST['h'] = '0';
if (isset($_REQUEST['h'])) {
    $h = $_REQUEST['h'];
    if (strpos($h, ',')) {
        $h = split(',', $h);
    } else {
        $h = array($h);
    }
    foreach ($h as $n) {
        $submit_headers[] = $headers[$n];
    }
}
if (@$_REQUEST['headers']) {
    $submit_headers = $_REQUEST['headers'];
}
function toRFC1123($time = null)
{
    if (is_null($time)) {
Exemple #25
0
<?php

// $CVSHeader: _freebeer/www/demo/System.php,v 1.3 2004/03/07 19:16:21 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/System.php';
echo html_header_demo('fbSystem Class', FREEBEER_BASE . '/lib/System.php');
echo "\n<pre>\n";
echo 'platform=', fbSystem::platform(), "\n";
echo 'isCLI=', fbSystem::isCLI(), "\n";
echo 'isApache=', fbSystem::isApache(), "\n";
echo 'directorySeparator=', fbSystem::directorySeparator(), "\n";
$nl = fbSystem::lineSeparator();
echo 'lineSeparator=';
for ($i = 0; $i < strlen($nl); ++$i) {
    printf("%d: %d ", $i + 1, ord($nl[$i]));
}
echo "\n";
echo 'pathSeparator=', fbSystem::pathSeparator(), "\n";
echo 'tempDirectory=', fbSystem::tempDirectory(), "\n";
echo 'extensionSuffix=', fbSystem::extensionSuffix(), "\n";
echo 'hostname=', fbSystem::hostname(), "\n";
echo 'username='******'include_path=', ini_get('include_path'), "\n";
fbSystem::appendIncludePath('appendme');
echo 'include_path=', ini_get('include_path'), "\n";
fbSystem::prependIncludePath('prependme');
echo 'include_path=', ini_get('include_path'), "\n";
echo 'loadExtension(\'standard\')=', fbSystem::loadExtension('standard'), "\n";
echo 'loadExtension(\'curl\')=', fbSystem::loadExtension('curl'), "\n";
Exemple #26
0
<?php

// $CVSHeader: _freebeer/www/demo/get.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/Debug/PHP_Constants.php';
echo html_header_demo('Display PHP Information');
// change one, just to see the result
ini_set('SMTP', 'locally.changed.com');
$options = array(0 => 'all', 1 => 'get_declared_classes', 2 => 'get_loaded_extensions', 3 => 'get_extension_funcs', 4 => 'get_user_constants', 5 => 'get_defined_constants', 6 => 'ini_get_all', 7 => 'ini_get_all (different)', 8 => 'dba_handlers', 9 => 'system constants', 10 => 'stream_get_wrappers', 11 => '$_ENV', 12 => '$_SERVER');
if (!isset($_REQUEST['option'])) {
    $_REQUEST['option'] = 0;
}
if (!preg_match('/wget/i', $_SERVER['HTTP_USER_AGENT'])) {
    foreach ($options as $key => $value) {
        $url = $_SERVER['PHP_SELF'] . '?option=' . $key;
        printf("<a href=\"%s\">%s</a><br />\n", $url, $value);
    }
}
echo "<pre>\n";
echo "get_cfg_var('cfg_file_path')=";
echo get_cfg_var('cfg_file_path');
echo "\n";
echo "ini_get('cfg_file_path')=";
echo ini_get('cfg_file_path');
echo "\n";
function do_option($option)
{
    switch ($option) {
        case 0:
Exemple #27
0
<?php

// $CVSHeader: _freebeer/www/demo/lib.RSA.php,v 1.2 2004/03/07 17:51:34 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
$title = 'JavaScript RSA Class (Public Key Cryptography)';
echo html_header_demo($title, array('../opt/ohdave.com/BigInt.js', '../opt/ohdave.com/RSA.js'));
?>
<!--
	RSA key parameters:

	p1 = 37751404861025150047
	p2 = 64845143588964943

	n = p1 * p2 =
	  = 2447995268898324993537772139997802321 (decimal)
	  = 01D7777C38863AEC21BA2D91EE0FAF51      (hex)

	phi(n) = phi(p1) * phi(p2) = (p1 - 1) * (p2 - 1)
	       = 2447995268898324955721522135383687332 (decimal)
	       = 01D7777C38863AEA14EBDE8CC7AC40A4      (hex)

	e = 23227 (decimal)
	  = 5abb  (hex)

	d = multiplicative inverse of e mod phi(n)
	  = a number such that 23227 * d =~ 1 (mod
	                                       2447995268898324955721522135383687332)
	  =~ 1435260669559451898523945771716323851 (decimal)
	  =~ 1146BD07F0B74C086DF00B37C602A0B       (hex)
Exemple #28
0
<?php

// $CVSHeader: _freebeer/www/demo/GeoIP.Free.Binary.php,v 1.3 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/GeoIP/Free/Binary.php';
echo html_header_demo('fbGeoIP_Free_Binary Class');
echo "<pre>\n";
$ips = array('0.0.0.0', '10.0.0.1', '10.255.255.255', '127.0.0.1', '127.0.0.2', '127.255.255.255', '127.255.255.255', '172.16.0.0', '172.31.255.255', '192.168.0.0', '192.168.0.1', '192.168.255.255', '217.194.16.0', '217.194.16.1', '255.0.0.0', '255.255.255.254', '255.255.255.255', '9.20.0.0');
foreach ($ips as $ip) {
    $rv = fbGeoIP_Free_Binary::getCountryIDByIP($ip);
    printf("%-20s: '%s'\n", $ip, $rv);
}
echo "\n";
flush();
$hosts = array('localhost', 'sf.net');
foreach ($hosts as $host) {
    $rv = fbGeoIP_Free_Binary::getCountryIDByHostName($host);
    printf("%-20s: '%s'\n", $host, $rv);
}
?>
<address>
$CVSHeader: _freebeer/www/demo/GeoIP.Free.Binary.php,v 1.3 2004/03/07 17:51:33 ross Exp $
</address>

</body>
</html>
Exemple #29
0
function dumpElapsedCallback($buffer)
{
    global $timer;
    $search = '~(</body\\s*>)~i';
    $replace = sprintf("Elapsed time: %.6f seconds\n\\1", $timer->elapsed());
    return preg_replace($search, $replace, $buffer);
}
ob_start('ob_gzhandler');
#ob_start('dumpElapsedCallback');
#session_start();
#if (isset($_SERVER['HTTP_REFERER']) && !isset($_SESSION['fbHTTPS']['HTTP_REFERER'])) {
#	$_SESSION['fbHTTPS']['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'];
#}
#$path = isset($_SESSION['fbHTTPS']['HTTP_REFERER']) ? $_SESSION['fbHTTPS']['HTTP_REFERER'] : '';
$path = '';
echo html_header_demo($title);
//echo fbHTTPS::isHttps() ? 'Secure (HTTPS)' : 'Not secure (HTTP)';
echo '<br />';
//$rng = &fbRandom_Best::bestNonBlockingRNG();
for ($i = 0; $i < 10000; ++$i) {
    echo "<!--\n";
    echo $data;
    echo "\n-->\n";
}
?>

<form action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" method="post">
<input type='submit' name='https' value='https' />
Exemple #30
0
<?php

// $CVSHeader: _freebeer/www/demo/Random.php,v 1.2 2004/03/07 17:51:33 ross Exp $
// Copyright (c) 2002-2004, Ross Smith.  All rights reserved.
// Licensed under the BSD or LGPL License. See license.txt for details.
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/Random.php';
require_once FREEBEER_BASE . '/lib/Random/Rand.php';
require_once FREEBEER_BASE . '/lib/Random/MT_Rand.php';
require_once FREEBEER_BASE . '/lib/Random/DevRandom.php';
require_once FREEBEER_BASE . '/lib/Random/DevUrandom.php';
require_once FREEBEER_BASE . '/lib/Random/Win32.php';
require_once FREEBEER_BASE . '/lib/Random/LCG.php';
require_once FREEBEER_BASE . '/lib/Random/GMP.php';
echo html_header_demo('fbRandom_Best Class');
$random = isset($_REQUEST['random']) ? $_REQUEST['random'] : false;
$choices = array('fbRandom_MT_Rand', 'fbRandom_Rand', 'fbRandom_DevRandom', 'fbRandom_DevUrandom', 'fbRandom_Win32', 'fbRandom_LCG', 'fbRandom_GMP', 'blocking', 'seedable', 'blocking_seedable');
$selected = array();
foreach ($choices as $choice) {
    $selected[$choice] = $random == $choice ? ' selected="selected" ' : '';
}
switch ($random) {
    case 'fbRandom_Rand':
        $fb_random =& new fbRandom_Rand();
        break;
    case 'fbRandom_MT_Rand':
        $fb_random =& new fbRandom_MT_Rand();
        break;
    case 'fbRandom_DevRandom':
        $fb_random =& new fbRandom_DevRandom();
        break;