Add unobfuscated code from @SirWumpus
The entries 2004/hibachi and 2005/mynx have unobfuscated code now. 2004/hibachi has a configure script that is used along the lines of the original entry (with some adjustments and fixes) and the hibachi.alt.c had to have ctype.h included too. The directory src/localhost was copied to src-alt/localhost but the rest of src/ was from Anthony. The Makefile had to be updated to build this version. 2005/mynx does have a configure script but it is, just like the original entry, unused and so the unobfuscated (in source-alt/) is also unused. The mynx.alt.c was changed to mynx.alt2.c and the unobfuscated code was made mynx.alt.c. Updated manifest, rebuilt .entry.json and index.html files. After a question is answered and taken care of (in one of 199[1-3]/ant - not sure which one) issue #2513 can possibly be closed as complete (though the manifest updates will have to be looked at more when 2004 and 2005 are reviewed).
This commit is contained in:
1 parent
60ce3d9155
commit
0d65af1b2b
65 files changed
+15579
-218
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Stock Price Example in Perl
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
<script language="JavaScript" type="text/javascript" src="yahoo-ticker.pl?DIR.V"></script>
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<h2>Stock Price Fetch Example in Perl</h2>
|
||||
<p>
|
||||
(This example requires JavaScript.)
|
||||
</p>
|
||||
|
||||
<table border="0" style="margin: 30 20 30 0;">
|
||||
<tr>
|
||||
<td rowspan="7">
|
||||
|
||||
</td>
|
||||
<th style="text-align: right;">Exchange : </th><td>CDNX</td>
|
||||
</tr><tr>
|
||||
<th style="text-align: right;">Symbol : </th><td>DIR</td>
|
||||
</tr><tr>
|
||||
<th style="text-align: right;">Share Price : </th>
|
||||
<td>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
document.write(ticker['price']);
|
||||
</script>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="text-align: right;">Volume : </th>
|
||||
<td>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
document.write(ticker['volume']);
|
||||
</script>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th style="text-align: right;">Last Trade : </th>
|
||||
<td>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
document.write(ticker['last']);
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr/>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# yahoo-ticker.pl
|
||||
#
|
||||
# Copyright 1998 by Anthony Howe. All rights reserved.
|
||||
#
|
||||
# Usage: yahoo-ticker.pl?<symbol>
|
||||
#
|
||||
|
||||
##########################################################################
|
||||
# Nothing to be configured below this point.
|
||||
##########################################################################
|
||||
|
||||
use Socket;
|
||||
|
||||
# WORK-AROUND 1.
|
||||
# BAH! Some Perl implementations (for Windows) are not created equal.
|
||||
# Force I/O flushes after each read/write operation.
|
||||
|
||||
$| = 1;
|
||||
|
||||
#########################################################################
|
||||
# Open connection to URL.
|
||||
#########################################################################
|
||||
|
||||
my ($symbol) = $ENV{'QUERY_STRING'} =~ /\??(.*)/;
|
||||
|
||||
# Figure out who we have to call.
|
||||
#($host, $port, $path) = ($url =~ m!http://([^:/]+)(?:\:(\d*))?(/.*)!);
|
||||
|
||||
$host = "finance.yahoo.com";
|
||||
$port = 80 unless defined $port;
|
||||
$path = "/q?s=$symbol";
|
||||
|
||||
# Get a socket...
|
||||
unless (socket(HTTP, PF_INET, SOCK_STREAM, getprotobyname('tcp'))) {
|
||||
print("[CGI failed ($!)]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
# ...set socket to be line buffered...
|
||||
select( (select(HTTP), $| = 1)[0] );
|
||||
|
||||
# .. make the connection.
|
||||
unless (connect(HTTP, sockaddr_in($port, inet_aton("$host")))) {
|
||||
print("[CGI failed ($!)]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
print HTTP "GET $path HTTP/1.0\nHost: $host\n\n";
|
||||
|
||||
while (<HTTP>) {
|
||||
# Last trade price line.
|
||||
if (m!>Last Trade:<!) {
|
||||
($price) = (m!Last Trade:</td><td class="yfnc_tabledata1"><big><b>(\d+\.\d+)</b></big></td>!);
|
||||
}
|
||||
|
||||
if (m!>Trade Time:<!) {
|
||||
($last) = (m!Trade Time:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
||||
}
|
||||
|
||||
if (m!>Volume:<!) {
|
||||
($volume) = (m!Volume:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
||||
}
|
||||
}
|
||||
|
||||
close(HTTP);
|
||||
|
||||
print "HTTP/1.0 200 OK\n";
|
||||
print "Content-Type: text/javascript\n\n";
|
||||
|
||||
print "var ticker = new Array();\n";
|
||||
print "ticker['price'] = $price;\n";
|
||||
print "ticker['volume'] = \"$volume\";\n";
|
||||
print "ticker['last'] = \"$last\";\n";
|
||||
|
||||
exit 0;
|
||||
@@ -0,0 +1,77 @@
|
||||
#!@perl_exe@
|
||||
#
|
||||
# yahoo-ticker.pl
|
||||
#
|
||||
# Copyright 1998 by Anthony Howe. All rights reserved.
|
||||
#
|
||||
# Usage: yahoo-ticker.pl?<symbol>
|
||||
#
|
||||
|
||||
##########################################################################
|
||||
# Nothing to be configured below this point.
|
||||
##########################################################################
|
||||
|
||||
use Socket;
|
||||
|
||||
# WORK-AROUND 1.
|
||||
# BAH! Some Perl implementations (for Windows) are not created equal.
|
||||
# Force I/O flushes after each read/write operation.
|
||||
|
||||
$| = 1;
|
||||
|
||||
#########################################################################
|
||||
# Open connection to URL.
|
||||
#########################################################################
|
||||
|
||||
my ($symbol) = $ENV{'QUERY_STRING'} =~ /\??(.*)/;
|
||||
|
||||
# Figure out who we have to call.
|
||||
#($host, $port, $path) = ($url =~ m!http://([^:/]+)(?:\:(\d*))?(/.*)!);
|
||||
|
||||
$host = "finance.yahoo.com";
|
||||
$port = 80 unless defined $port;
|
||||
$path = "/q?s=$symbol";
|
||||
|
||||
# Get a socket...
|
||||
unless (socket(HTTP, PF_INET, SOCK_STREAM, getprotobyname('tcp'))) {
|
||||
print("[CGI failed ($!)]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
# ...set socket to be line buffered...
|
||||
select( (select(HTTP), $| = 1)[0] );
|
||||
|
||||
# .. make the connection.
|
||||
unless (connect(HTTP, sockaddr_in($port, inet_aton("$host")))) {
|
||||
print("[CGI failed ($!)]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
print HTTP "GET $path HTTP/1.0\nHost: $host\n\n";
|
||||
|
||||
while (<HTTP>) {
|
||||
# Last trade price line.
|
||||
if (m!>Last Trade:<!) {
|
||||
($price) = (m!Last Trade:</td><td class="yfnc_tabledata1"><big><b>(\d+\.\d+)</b></big></td>!);
|
||||
}
|
||||
|
||||
if (m!>Trade Time:<!) {
|
||||
($last) = (m!Trade Time:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
||||
}
|
||||
|
||||
if (m!>Volume:<!) {
|
||||
($volume) = (m!Volume:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
||||
}
|
||||
}
|
||||
|
||||
close(HTTP);
|
||||
|
||||
print "HTTP/1.0 200 OK\n";
|
||||
print "Content-Type: text/javascript\n\n";
|
||||
|
||||
print "var ticker = new Array();\n";
|
||||
print "ticker['price'] = $price;\n";
|
||||
print "ticker['volume'] = \"$volume\";\n";
|
||||
print "ticker['last'] = \"$last\";\n";
|
||||
|
||||
exit 0;
|
||||
@@ -0,0 +1,557 @@
|
||||
<?
|
||||
class Date
|
||||
{
|
||||
var $date;
|
||||
var $time;
|
||||
|
||||
//
|
||||
// Create a new date object set to the time now.
|
||||
//
|
||||
function Date()
|
||||
{
|
||||
$this->setTime(time());
|
||||
}
|
||||
|
||||
function isLeapYear(/* year */)
|
||||
{
|
||||
if (func_num_args() == 1)
|
||||
$year = func_get_arg(0);
|
||||
else
|
||||
$year = $this->date['year'];
|
||||
|
||||
if ($year % 4000 == 0)
|
||||
return false;
|
||||
if ($year % 400 == 0)
|
||||
return true;
|
||||
if ($year % 100 == 0)
|
||||
return false;
|
||||
if ($year % 4 == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the number of seconds since system epoch.
|
||||
//
|
||||
function getTime()
|
||||
{
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the date / time in seconds for the object.
|
||||
//
|
||||
function setTime($t)
|
||||
{
|
||||
$this->time = $t;
|
||||
$this->date = getdate($t);
|
||||
}
|
||||
|
||||
function getHour()
|
||||
{
|
||||
return $this->date['hour'];
|
||||
}
|
||||
|
||||
function getMinute()
|
||||
{
|
||||
return $this->date['minutes'];
|
||||
}
|
||||
|
||||
function getSecond()
|
||||
{
|
||||
return $this->date['seconds'];
|
||||
}
|
||||
|
||||
function getMonth()
|
||||
{
|
||||
return $this->date['mon'];
|
||||
}
|
||||
|
||||
function getYear()
|
||||
{
|
||||
return $this->date['year'];
|
||||
}
|
||||
|
||||
function getDayOfWeek()
|
||||
{
|
||||
return $this->date['wday'];
|
||||
}
|
||||
|
||||
function getDayOfMonth()
|
||||
{
|
||||
return $this->date['mday'];
|
||||
}
|
||||
|
||||
function getDayOfYear()
|
||||
{
|
||||
return $this->date['yday'];
|
||||
}
|
||||
|
||||
function getDaysInMonth(/* year, month */)
|
||||
{
|
||||
if (func_num_args() == 2) {
|
||||
$year = func_get_arg(0);
|
||||
$month = func_get_arg(1);
|
||||
} else {
|
||||
$year = $this->date['year'];
|
||||
$month = $this->date['mon'];
|
||||
}
|
||||
|
||||
$endOfMonth = Array(
|
||||
31,
|
||||
28 + Date::isLeapYear($year),
|
||||
31,
|
||||
30,
|
||||
31,
|
||||
30,
|
||||
31,
|
||||
31,
|
||||
30,
|
||||
31,
|
||||
30,
|
||||
31
|
||||
);
|
||||
|
||||
return $endOfMonth[$month-1];
|
||||
}
|
||||
|
||||
function getPreviousMonth()
|
||||
{
|
||||
if ($this->date['mon'] <= 1)
|
||||
return 12;
|
||||
|
||||
return $this->date['mon']-1;
|
||||
}
|
||||
|
||||
function getNextMonth()
|
||||
{
|
||||
if (12 <= $this->date['mon'])
|
||||
return 1;
|
||||
|
||||
return $this->date['mon']+1;
|
||||
}
|
||||
|
||||
function getFirstWeekDayOfMonth(/* year, month */)
|
||||
{
|
||||
if (func_num_args() == 2) {
|
||||
$y = func_get_arg(0);
|
||||
$m = func_get_arg(1);
|
||||
} else {
|
||||
$y = $this->date['year'];
|
||||
$m = $this->date['mon'];
|
||||
}
|
||||
|
||||
// Day of the week 0..6 (Sunday..Saturday).
|
||||
$weekDay = strftime("%w", mktime(0, 0, 0, $m, 1, $y));
|
||||
|
||||
// Day of the week 1..7 (Monday..Sunday).
|
||||
return $weekDay == 0 ? 7 : $weekDay;
|
||||
}
|
||||
|
||||
function getNumberOfWeeks(/* year */)
|
||||
{
|
||||
if (func_num_args() == 1)
|
||||
$year = func_get_arg(0);
|
||||
else
|
||||
$year = $this->date['year'];
|
||||
|
||||
/* An ISO calendar year y is long (contains 53 weeks) if:
|
||||
*
|
||||
* p(y) modulo 7 = 4
|
||||
*
|
||||
* or if:
|
||||
*
|
||||
* p(y-1) modulo 7 = 3
|
||||
*
|
||||
* with:
|
||||
*
|
||||
* p(y) = y + floor(y/4) - floor(y/100) + floor(y/400)
|
||||
*
|
||||
* http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
|
||||
*/
|
||||
|
||||
if (($year + floor($year/4) - floor($year/100) + floor($year/400)) % 7 == 4)
|
||||
return 53;
|
||||
|
||||
if ((--$year + floor($year/4) - floor($year/100) + floor($year/400)) % 7 == 3)
|
||||
return 53;
|
||||
|
||||
return 52;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return ISO 8601:2000(E) week number. This is a work around for
|
||||
* Windows, which does not support a working strftime %V format.
|
||||
*/
|
||||
function getWeekNumber(/* year, month, day */)
|
||||
{
|
||||
if (func_num_args() == 3) {
|
||||
$year = func_get_arg(0);
|
||||
$month = func_get_arg(1);
|
||||
$day = func_get_arg(2);
|
||||
} else {
|
||||
$year = $this->date['year'];
|
||||
$month = $this->date['mon'];
|
||||
$day = $this->date['mday'];
|
||||
}
|
||||
|
||||
/* The week number of the current year as a decimal number, range
|
||||
* 00 to 53, starting with the first Monday as the first day of
|
||||
* week 01.
|
||||
*/
|
||||
$week = strftime("%W", mktime(0, 0, 0, $month, $day, $year));
|
||||
|
||||
/* Week days numbered 0 (Sunday) to 6 (Saturday). */
|
||||
$firstWeekDayThisYear = strftime("%w", mktime(0, 0, 0, 1, 1, $year));
|
||||
$firstWeekDayNextYear = strftime("%w", mktime(0, 0, 0, 1, 1, $year+1));
|
||||
|
||||
/* The first ISO calendar week of a year is the one that includes the
|
||||
* first Thursday of that year. In other words, the first week of the
|
||||
* ISO calendar year is the earliest week that contains at least four
|
||||
* days of the month of January.
|
||||
*/
|
||||
if (1 < $firstWeekDayThisYear && $firstWeekDayThisYear < 5) {
|
||||
/* The first Thursday of the current ISO year was in week zero. */
|
||||
$week++;
|
||||
}
|
||||
|
||||
if ($week == 53 && 1 < $firstWeekDayNextYear && $firstWeekDayNextYear < 5) {
|
||||
/* The first Thursday of the following ISO year is this week. */
|
||||
$week = 1;
|
||||
}
|
||||
|
||||
if ($week == 0) {
|
||||
/* Number of weeks last year. */
|
||||
$week = Date::getNumberOfWeeks($year-1);
|
||||
}
|
||||
|
||||
return $week+0;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the number seconds as of zero hour today.
|
||||
//
|
||||
function getDate()
|
||||
{
|
||||
return mktime(0, 0, 0, $this->date['mon'], $this->date['mday'], $this->date['year']);
|
||||
}
|
||||
|
||||
//
|
||||
// Set date as of zero hour that day.
|
||||
//
|
||||
function setDate($year, $month, $day)
|
||||
{
|
||||
$this->setDateTime($year, $month, $day, 0, 0, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// Return the date / time array.
|
||||
//
|
||||
function getDateTime()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the date / time for the object.
|
||||
//
|
||||
function setDateTime($year, $month, $day, $hour, $minute, $second)
|
||||
{
|
||||
$time = mktime($hour, $minute, $second, $month, $day, $year, 0);
|
||||
$this->setTime($time);
|
||||
}
|
||||
|
||||
//
|
||||
// Adjust the date / time of the object.
|
||||
//
|
||||
function addDateTime($year, $month, $day, $hour, $minute, $second)
|
||||
{
|
||||
$t = mktime(
|
||||
$this->date['hour'] + $hour,
|
||||
$this->date['minutes'] + $minute,
|
||||
$this->date['seconds'] + $second,
|
||||
$this->date['mon'] + $month,
|
||||
$this->date['mday'] + $day,
|
||||
$this->date['year'] + $year
|
||||
);
|
||||
$this->setTime($t);
|
||||
}
|
||||
|
||||
//
|
||||
// Return the date / time as an ISO date string.
|
||||
//
|
||||
function getDateISO()
|
||||
{
|
||||
return strftime("%Y-%m-%d %H:%M:%S", $this->time);
|
||||
}
|
||||
|
||||
//
|
||||
// Set the date / time of the object using an ISO date string.
|
||||
//
|
||||
function setDateISO($str)
|
||||
{
|
||||
if (!ereg('([0-9]+)-([0-9]+)-([0-9]+)', $str, $ymd))
|
||||
$ymd = array('','0','0','0');
|
||||
if (!ereg('([0-9]+):([0-9]+):([0-9]+)\+([0-9]+)', $str, $hms))
|
||||
$hms = array('','0','0','0');
|
||||
|
||||
// Assume local time, ignore timezone.
|
||||
$this->setDateTime(
|
||||
intval($ymd[1]),
|
||||
intval($ymd[2]),
|
||||
intval($ymd[3]),
|
||||
intval($hms[1]),
|
||||
intval($hms[2]),
|
||||
intval($hms[3])
|
||||
);
|
||||
}
|
||||
|
||||
function setDateMySQL($str)
|
||||
{
|
||||
$n = sscanf($str, "%4d%2d%2d%2d%2d%2d", $y, $m, $d, $H, $M, $S);
|
||||
$this->setDateTime($y, $m, $d, $H, $M, $S);
|
||||
}
|
||||
|
||||
//
|
||||
// Relational operations between Date vs time or Date vs Date.
|
||||
//
|
||||
function eq($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time == $t;
|
||||
}
|
||||
|
||||
function ne($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time != $t;
|
||||
}
|
||||
|
||||
function lt($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time < $t;
|
||||
}
|
||||
|
||||
function le($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time <= $t;
|
||||
}
|
||||
|
||||
function gt($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time > $t;
|
||||
}
|
||||
|
||||
function ge($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time >= $t;
|
||||
}
|
||||
|
||||
/*
|
||||
* $obj->getSmallCalendar()
|
||||
* Date::getSmallCalendar($year, $month)
|
||||
*/
|
||||
function getSmallCalendar(/* [$year, $month] */)
|
||||
{
|
||||
if (func_num_args() == 2) {
|
||||
$year = func_get_arg(0);
|
||||
$month = func_get_arg(1);
|
||||
} else {
|
||||
$year = $this->date['year'];
|
||||
$month = $this->date['mon'];
|
||||
}
|
||||
|
||||
$name = date('F', mktime(0,0,0,$month,1,$year));
|
||||
$weekNumber = Date::getWeekNumber($year, $month, 1);
|
||||
$daysInMonth = Date::getDaysInMonth($year, $month);
|
||||
$weekDay = Date::getFirstWeekDayOfMonth($year, $month) - 1;
|
||||
|
||||
$thisDate = getdate(time());
|
||||
$thisDay = mktime(0, 0, 0, $thisDate['mon'], $thisDate['mday'], $thisDate['year']);
|
||||
$thisWeek = Date::getWeekNumber($thisDate['year'], $thisDate['mon'], $thisDate['mday']);
|
||||
|
||||
if ($year != $thisDate['year']) {
|
||||
$thisWeek = 0;
|
||||
}
|
||||
|
||||
$rc = <<<EOT
|
||||
<table class="smCalendarTable">
|
||||
<tr>
|
||||
<td class="smCalendarCell smCalendarMonthTitle" colspan="8" align="center">{$name} {$year}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="smCalendarCell smCalendarDayTitle"> </td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Mo</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Tu</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">We</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Th</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Fr</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Sa</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Su</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="smCalendarCell smCalendarWeekNumber" valign='top'>{$weekNumber}</td>
|
||||
|
||||
EOT;
|
||||
|
||||
if ($weekNumber == $thisWeek) {
|
||||
$style = "smCalendarThisWeek";
|
||||
$thisDayStyle = "smCalendarThisWeek smCalendarThisDay";
|
||||
} else {
|
||||
$style = $thisDayStyle = "smCalendarDay";
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $weekDay; $i++) {
|
||||
$rc .= sprintf(
|
||||
"\t<td class='smCalendarCell %s%s'> </td>\n",
|
||||
$i == $thisDate['wday'] ? $thisDayStyle : $style,
|
||||
$i < 5 ? "" : " smCalendarWeekend"
|
||||
);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $daysInMonth; $i++, $weekDay = ($weekDay + 1) % 7) {
|
||||
if (1 < $i && $weekDay == 0) {
|
||||
$weekNumber = Date::getWeekNumber($year, $month, $i);
|
||||
|
||||
$week = $weekNumber < 10 ? " {$weekNumber}" : $weekNumber;
|
||||
$rc .= "</tr>\n<tr>\n\t<td class='smCalendarCell smCalendarWeekNumber' valign='top'>{$week}</td>\n";
|
||||
if ($weekNumber == $thisWeek) {
|
||||
$style = "smCalendarThisWeek";
|
||||
$thisDayStyle = "smCalendarThisWeek smCalendarThisDay";
|
||||
} else {
|
||||
$style = $thisDayStyle = "smCalendarDay";
|
||||
}
|
||||
}
|
||||
|
||||
$key = sprintf("%04d-02d-02d", $year, $month, $i);
|
||||
|
||||
$rc .= sprintf(
|
||||
"\t<td class='smCalendarCell %s%s' valign='top'><span class='smCalendarNumber'>%d</span></td>\n",
|
||||
$i == $thisDate['mday'] ? $thisDayStyle : $style,
|
||||
$weekDay < 5 ? "" : " smCalendarWeekend", $i
|
||||
);
|
||||
}
|
||||
|
||||
for ( ; $weekDay != 0; $weekDay = ($weekDay + 1) % 7) {
|
||||
$rc .= sprintf(
|
||||
"\t<td class='smCalendarCell %s'> </td>\n",
|
||||
$weekDay < 5 ? "smCalendarDay" : "smCalendarWeekend"
|
||||
);
|
||||
}
|
||||
|
||||
$rc .= "</tr>\n</table>\n";
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* $obj->getLargeCalendar($notes)
|
||||
* Date::getLargeCalendar($notes, $year, $month)
|
||||
*/
|
||||
function getLargeCalendar(/* $notes [, $year, $month] */)
|
||||
{
|
||||
switch (func_num_args()) {
|
||||
case 3:
|
||||
$notes = func_get_arg(0);
|
||||
$year = func_get_arg(1);
|
||||
$month = func_get_arg(2);
|
||||
break;
|
||||
case 1:
|
||||
$notes = func_get_arg(0);
|
||||
$year = $this->date['year'];
|
||||
$month = $this->date['mon'];
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
$name = date('F', mktime(0,0,0,$month,1,$year));
|
||||
$weekNumber = Date::getWeekNumber($year, $month, 1);
|
||||
$daysInMonth = Date::getDaysInMonth($year, $month);
|
||||
$weekDay = Date::getFirstWeekDayOfMonth($year, $month) - 1;
|
||||
|
||||
$thisDate = getdate(time());
|
||||
$thisDay = mktime(0, 0, 0, $thisDate['mon'], $thisDate['mday'], $thisDate['year']);
|
||||
$thisWeek = Date::getWeekNumber($thisDate['year'], $thisDate['mon'], $thisDate['mday']);
|
||||
|
||||
if ($year != $thisDate['year']) {
|
||||
$thisWeek = 0;
|
||||
}
|
||||
|
||||
$rc = <<<EOT
|
||||
<table class="lgCalendarTable">
|
||||
<tr>
|
||||
<td class="lgCalendarCell lgCalendarMonthTitle" colspan="8" align="center">{$name} {$year}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="2%">W</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Mo</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Tu</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">We</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Th</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Fr</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Sa</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Su</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lgCalendarCell lgCalendarWeekNumber" valign='top' style='padding-left: 0; padding-right: 1;'><img align='left' width='1' height='80' src='pixel.gif'>{$weekNumber}</td>
|
||||
|
||||
EOT;
|
||||
|
||||
if ($weekNumber == $thisWeek) {
|
||||
$style = "lgCalendarThisWeek";
|
||||
$thisDayStyle = "lgCalendarThisWeek lgCalendarThisDay";
|
||||
} else {
|
||||
$style = $thisDayStyle = "lgCalendarDay";
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $weekDay; $i++) {
|
||||
$rc .= sprintf(
|
||||
"\t<td class='lgCalendarCell %s%s'> </td>\n",
|
||||
$i == $thisDate['wday'] ? $thisDayStyle : $style,
|
||||
$i < 5 ? "" : " lgCalendarWeekend"
|
||||
);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $daysInMonth; $i++, $weekDay = ($weekDay + 1) % 7) {
|
||||
if (1 < $i && $weekDay == 0) {
|
||||
$weekNumber = Date::getWeekNumber($year, $month, $i);
|
||||
|
||||
$week = $weekNumber < 10 ? " {$weekNumber}" : $weekNumber;
|
||||
$rc .= "</tr>\n<tr>\n\t<td class='lgCalendarCell lgCalendarWeekNumber' valign='top' style='padding-left: 0; padding-right: 1;'><img align='left' width='1' height='80' src='pixel.gif'>{$week}</td>\n";
|
||||
if ($weekNumber == $thisWeek) {
|
||||
$style = "lgCalendarThisWeek";
|
||||
$thisDayStyle = "lgCalendarThisWeek lgCalendarThisDay";
|
||||
} else {
|
||||
$style = $thisDayStyle = "lgCalendarDay";
|
||||
}
|
||||
}
|
||||
|
||||
$key = sprintf("%04d-%02d-%02d", $year, $month, $i);
|
||||
|
||||
$rc .= sprintf(
|
||||
"\t<td class='lgCalendarCell %s%s' valign='top' style='text-align: left;'><span class='lgCalendarNumber'>%d </span>%s</td>\n",
|
||||
$i == $thisDate['mday'] ? $thisDayStyle : $style,
|
||||
$weekDay < 5 ? "" : " lgCalendarWeekend",
|
||||
$i, isset($notes[$key]) ? $notes[$key] : ''
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
for ( ; $weekDay != 0; $weekDay = ($weekDay + 1) % 7) {
|
||||
$rc .= sprintf(
|
||||
"\t<td class='lgCalendarCell %s'> </td>\n",
|
||||
$weekDay < 5 ? "lgCalendarDay" : "lgCalendarWeekend"
|
||||
);
|
||||
}
|
||||
|
||||
$rc .= "</tr>\n</table>\n";
|
||||
|
||||
return $rc;
|
||||
}
|
||||
}
|
||||
?>
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
header("HTTP/1.0 299 OK");
|
||||
header("Content-Type: text/html");
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - A Calendar Generator in PHP
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
<style>
|
||||
<!--
|
||||
.smCalendarTable {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 9pt;
|
||||
border-spacing: 0;
|
||||
border-width: 1;
|
||||
border-style: groove;
|
||||
}
|
||||
.smCalendarCell {
|
||||
padding: 3;
|
||||
text-align: right;
|
||||
}
|
||||
.smCalendarMonthTitle {
|
||||
color: #ff0000;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
border-color: #000000;
|
||||
border-width: 2 0 0 0;
|
||||
border-style: solid;
|
||||
}
|
||||
.smCalendarDayTitle {
|
||||
color: #0000cc;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
border-color: #000000;
|
||||
border-width: 1 0 1 0;
|
||||
border-style: solid;
|
||||
}
|
||||
.smCalendarWeekNumber {
|
||||
color: #cc00cc;
|
||||
font-weight: bold;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
.smCalendarDay {
|
||||
color: #0000cc;
|
||||
}
|
||||
.smCalendarWeekend {
|
||||
color: #0000cc;
|
||||
background-color: #cae4ff;
|
||||
}
|
||||
.smCalendarThisWeek {
|
||||
color: #0000cc;
|
||||
background-color: #ffcccc;
|
||||
}
|
||||
.smCalendarThisDay {
|
||||
padding: 1;
|
||||
border-color: #ff0000;
|
||||
border-width: 2;
|
||||
border-style: solid;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<div align="center">
|
||||
<table border="0" cellspacing="0" cellpadding="5">
|
||||
<h2>A Calendar Generator in PHP</h2>
|
||||
<?
|
||||
include('Date.php');
|
||||
$date = new Date();
|
||||
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
if ($i % 4 == 0)
|
||||
print("<tr valign='top'>\n");
|
||||
|
||||
print("<td>");
|
||||
print Date::getSmallCalendar($date->getYear(), $i+1);
|
||||
print("</td>\n");
|
||||
|
||||
if ($i % 4 == 3)
|
||||
print("</tr>\n");
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,106 @@
|
||||
#!@php_exe@
|
||||
<?
|
||||
header("HTTP/1.0 299 OK");
|
||||
header("Content-Type: text/html");
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - A Calendar Generator in PHP
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
<style>
|
||||
<!--
|
||||
.smCalendarTable {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 9pt;
|
||||
border-spacing: 0;
|
||||
border-width: 1;
|
||||
border-style: groove;
|
||||
}
|
||||
.smCalendarCell {
|
||||
padding: 3;
|
||||
text-align: right;
|
||||
}
|
||||
.smCalendarMonthTitle {
|
||||
color: #ff0000;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
border-color: #000000;
|
||||
border-width: 2 0 0 0;
|
||||
border-style: solid;
|
||||
}
|
||||
.smCalendarDayTitle {
|
||||
color: #0000cc;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
border-color: #000000;
|
||||
border-width: 1 0 1 0;
|
||||
border-style: solid;
|
||||
}
|
||||
.smCalendarWeekNumber {
|
||||
color: #cc00cc;
|
||||
font-weight: bold;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
.smCalendarDay {
|
||||
color: #0000cc;
|
||||
}
|
||||
.smCalendarWeekend {
|
||||
color: #0000cc;
|
||||
background-color: #cae4ff;
|
||||
}
|
||||
.smCalendarThisWeek {
|
||||
color: #0000cc;
|
||||
background-color: #ffcccc;
|
||||
}
|
||||
.smCalendarThisDay {
|
||||
padding: 1;
|
||||
border-color: #ff0000;
|
||||
border-width: 2;
|
||||
border-style: solid;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<div align="center">
|
||||
<table border="0" cellspacing="0" cellpadding="5">
|
||||
<h2>A Calendar Generator in PHP</h2>
|
||||
<?
|
||||
include('Date.php');
|
||||
$date = new Date();
|
||||
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
if ($i % 4 == 0)
|
||||
print("<tr valign='top'>\n");
|
||||
|
||||
print("<td>");
|
||||
print Date::getSmallCalendar($date->getYear(), $i+1);
|
||||
print("</td>\n");
|
||||
|
||||
if ($i % 4 == 3)
|
||||
print("</tr>\n");
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
// Bug #27026: header('HTTP/1.0 200 OK') never sent when explicitly
|
||||
// requested.
|
||||
//
|
||||
// Send a 2xx status code not defined by RFC 2616. A 200 value would
|
||||
// be the correct value, but PHP/CGI refuses to send it when explicitly
|
||||
// set.
|
||||
//
|
||||
// This works for Opera 7, Mozilla 1.6, and IE 6.0 SP1.
|
||||
//
|
||||
header("HTTP/1.0 299 OK");
|
||||
phpinfo();
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#!@php_exe@
|
||||
<?
|
||||
// Bug #27026: header('HTTP/1.0 200 OK') never sent when explicitly
|
||||
// requested.
|
||||
//
|
||||
// Send a 2xx status code not defined by RFC 2616. A 200 value would
|
||||
// be the correct value, but PHP/CGI refuses to send it when explicitly
|
||||
// set.
|
||||
//
|
||||
// This works for Opera 7, Mozilla 1.6, and IE 6.0 SP1.
|
||||
//
|
||||
header("HTTP/1.0 299 OK");
|
||||
phpinfo();
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Hibachi - Form Processing Example in PHP
|
||||
</title>
|
||||
<meta name="description" content="Form Processing Example in PHP">
|
||||
<meta name="keywords" content="IOCCC, 2004/hibachi, from, PHP">
|
||||
</head>
|
||||
<body style="background-image: url(../../Img/hot-coal-edge-110-indent.png); padding: 0 0 0 10%;">
|
||||
|
||||
<h2>Form Processing Example in PHP</h2>
|
||||
|
||||
<p>This example takes the output of a form POST and reformats it from
|
||||
its encoded format into human readable output suitable for sending
|
||||
by email.
|
||||
</p>
|
||||
|
||||
<hr style="width:10%;text-align:left;margin-left:0">
|
||||
|
||||
<form method="POST" action="sendform.php">
|
||||
<table style="border-spacing: 0; padding: 0; margin-right:auto;">
|
||||
<tr style="vertical-align: top;">
|
||||
<td style="text-align: right;">
|
||||
Who am I?
|
||||
</td>
|
||||
<td>
|
||||
<input name="who" value="Snert" size="24">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align: top;">
|
||||
<td style="text-align: right;">
|
||||
What am I?
|
||||
</td>
|
||||
<td>
|
||||
<input name="what" value="A sick puppy" size="24">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align: top;">
|
||||
<td style="text-align: right;">
|
||||
Where am I?
|
||||
</td>
|
||||
<td>
|
||||
<textarea rows="4" cols="20" name="where" wrap="hard">I live in the south of France now.</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align: top;">
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" value="SEND">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<hr style="width:10%;text-align:left;margin-left:0">
|
||||
|
||||
<h3>The above PHP will NOT work on on www.ioccc.org, Sorry!</h3>
|
||||
|
||||
<hr style="width:10%;text-align:left;margin-left:0">
|
||||
|
||||
<a href="../../../../index.html">Return to 2004/hibachi</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
header("HTTP/1.0 299 OK");
|
||||
header("Content-Type: text/html");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CHANGE THE VALUES BELOW HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$SEND_TO = 'achowe@snert.com';
|
||||
$SUBJECT = 'From the web form...';
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CHANGE THE VALUES ABOVE HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$maxWidth = 0;
|
||||
|
||||
foreach ($_GET as $name => $value) {
|
||||
if ($maxWidth < strlen($name))
|
||||
$maxWidth = strlen($name);
|
||||
}
|
||||
|
||||
foreach ($_POST as $name => $value) {
|
||||
if ($maxWidth < strlen($name))
|
||||
$maxWidth = strlen($name);
|
||||
}
|
||||
|
||||
$body = '';
|
||||
$fmt = "%{$maxWidth}s: %s\n";
|
||||
|
||||
foreach ($_GET as $name => $value) {
|
||||
$body .= sprintf($fmt, $name, $value);
|
||||
}
|
||||
|
||||
foreach ($_POST as $name => $value) {
|
||||
$body .= sprintf($fmt, $name, $value);
|
||||
}
|
||||
|
||||
//mail($SEND_TO, $SUBJECT, $body);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Form Processing Example in PHP
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<h2>Form Processing Example in PHP</h2>
|
||||
|
||||
<p>Formatted output of web form as would be seen in an email message (without decorations).
|
||||
This example does not send any actual email, though it could with some minor changes.
|
||||
</p>
|
||||
<pre>
|
||||
<?= $body; ?>
|
||||
</pre>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#!@php_exe@
|
||||
<?
|
||||
header("HTTP/1.0 299 OK");
|
||||
header("Content-Type: text/html");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CHANGE THE VALUES BELOW HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$SEND_TO = 'achowe@snert.com';
|
||||
$SUBJECT = 'From the web form...';
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CHANGE THE VALUES ABOVE HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$maxWidth = 0;
|
||||
|
||||
foreach ($_GET as $name => $value) {
|
||||
if ($maxWidth < strlen($name))
|
||||
$maxWidth = strlen($name);
|
||||
}
|
||||
|
||||
foreach ($_POST as $name => $value) {
|
||||
if ($maxWidth < strlen($name))
|
||||
$maxWidth = strlen($name);
|
||||
}
|
||||
|
||||
$body = '';
|
||||
$fmt = "%{$maxWidth}s: %s\n";
|
||||
|
||||
foreach ($_GET as $name => $value) {
|
||||
$body .= sprintf($fmt, $name, $value);
|
||||
}
|
||||
|
||||
foreach ($_POST as $name => $value) {
|
||||
$body .= sprintf($fmt, $name, $value);
|
||||
}
|
||||
|
||||
//mail($SEND_TO, $SUBJECT, $body);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Form Processing Example in PHP
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<h2>Form Processing Example in PHP</h2>
|
||||
|
||||
<p>Formatted output of web form as would be seen in an email message (without decorations).
|
||||
This example does not send any actual email, though it could with some minor changes.
|
||||
</p>
|
||||
<pre>
|
||||
<?= $body; ?>
|
||||
</pre>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
#
|
||||
# LUHN.rb
|
||||
#
|
||||
# Copyright 2000, 2004 by Anthony Howe. All rights reserved.
|
||||
#
|
||||
|
||||
class LUHN
|
||||
def LUHN.base(str, radix)
|
||||
if radix < 2 then
|
||||
return nil
|
||||
end
|
||||
|
||||
num = 0
|
||||
str.downcase!
|
||||
str.each_byte do |byte|
|
||||
i = "0123456789abcdefghijklmnopqrstuvwxyz".index(byte)
|
||||
if i.nil? || radix <= i then
|
||||
return nil
|
||||
end
|
||||
num = num * radix + i
|
||||
end
|
||||
|
||||
return num
|
||||
end
|
||||
|
||||
#
|
||||
# Internal routine that computes the LUHN sum.
|
||||
#
|
||||
# The LUHN Algorithm ("mod 10 Double-Add-Double"):
|
||||
#
|
||||
# 1. Position from right 8 7 6 5 4 3 2 1
|
||||
# ------------------------------
|
||||
# Number string 4 8 9 5 1 3 1 3
|
||||
# x2 even positions 2 1 2 1 2 1 2 1
|
||||
# ------------------------------
|
||||
# Add odd positions & 8 +8 +1+8 +5 +2 +3 +2 +3
|
||||
# add digits of doubled
|
||||
# positions
|
||||
#
|
||||
# Sum 40
|
||||
#
|
||||
# Number is valid if sum is a multiple of 10.
|
||||
#
|
||||
#
|
||||
# 2. Alpha-numeric ISIN U S 3 8 3 8 8 3 1 0 5 1
|
||||
# (ISO 6166) -----------------------------------------
|
||||
# base 36 digits 30 28 3 8 3 8 8 3 1 0 5 1
|
||||
# -----------------------------------------
|
||||
# consider digit string 3 0 2 8 3 8 3 8 8 3 1 0 5 1
|
||||
# & x2 even digits from 2 1 2 1 2 1 2 1 2 1 2 1 2 1
|
||||
# -----------------------------------------
|
||||
# 6 0 4 8 6 8 6 8 16 3 2 0 10 1
|
||||
# -----------------------------------------
|
||||
# sum the digits of 6 +0 +4 +8 +6 +8 +6 +8+1+6+3 +2 +0+1+0+1
|
||||
#
|
||||
# Sum 60
|
||||
#
|
||||
# Number is valid if sum is a multiple of 10.
|
||||
#
|
||||
def LUHN.sum(str)
|
||||
if ! str.instance_of?(String) || str.length < 1 then
|
||||
return nil
|
||||
end
|
||||
|
||||
total = 0
|
||||
even = false
|
||||
str = str.reverse.downcase
|
||||
|
||||
# Working right to left...
|
||||
str.each_byte do |byte|
|
||||
# Convert base36 digit to a base10 value.
|
||||
digit36 = base(byte.chr, 36)
|
||||
if digit36.nil? then
|
||||
return nil
|
||||
end
|
||||
|
||||
# For each base10 digit of a base36 digit...
|
||||
begin
|
||||
digit10 = digit36 % 10
|
||||
|
||||
if even then
|
||||
# Multiply even digits by 2.
|
||||
digit10 <<= 1
|
||||
|
||||
# Sum digits of product.
|
||||
if 10 <= digit10 then
|
||||
digit10 -= 9
|
||||
end
|
||||
end
|
||||
|
||||
# Add digits of product to total.
|
||||
total += digit10
|
||||
|
||||
# Next digit.
|
||||
digit36 = (digit36 / 10).floor
|
||||
|
||||
# Toggle from digit to digit.
|
||||
even = !even
|
||||
end while 0 < digit36
|
||||
end
|
||||
|
||||
return total
|
||||
end
|
||||
|
||||
#
|
||||
# Return true if the string of digits is valid.
|
||||
# Assumes LUHN check digit is right most digit.
|
||||
#
|
||||
def LUHN.valid?(str)
|
||||
if ! str.instance_of?(String) || str.length < 2 then
|
||||
return false
|
||||
end
|
||||
|
||||
total = sum(str)
|
||||
|
||||
return total.nil? ? false : (total % 10) == 0
|
||||
end
|
||||
|
||||
#
|
||||
# Return the LUHN check digit (mod 10) for the
|
||||
# given string of digits; otherwise nil on error.
|
||||
#
|
||||
def LUHN.generate(str)
|
||||
if ! str.instance_of?(String) || str.length < 1 then
|
||||
return nil
|
||||
end
|
||||
|
||||
total = sum(str + '0')
|
||||
|
||||
return total.nil? ? nil : (10 - (total % 10)) % 10
|
||||
end
|
||||
end
|
||||
|
||||
if $DEBUG && $0 == 'LUHN.rb' then
|
||||
def generate(str, expect)
|
||||
digit = LUHN.generate(str)
|
||||
puts(str + "-" + digit.to_s + ' ' + (digit == expect).to_s)
|
||||
end
|
||||
def validate(str)
|
||||
puts(str + ' ' + LUHN.valid?(str).to_s)
|
||||
end
|
||||
|
||||
generate('1', 8)
|
||||
generate('12', 5)
|
||||
generate('123', 0)
|
||||
generate('A', 9)
|
||||
generate('AB', 6)
|
||||
|
||||
validate('AB6')
|
||||
end
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'cgi'
|
||||
require ENV['DOCUMENT_ROOT'] + '/test/ruby/LUHN'
|
||||
|
||||
if ENV['QUERY_STRING'].nil? then
|
||||
answer = ''
|
||||
numebr = ''
|
||||
else
|
||||
query = CGI.parse(ENV['QUERY_STRING'])
|
||||
number = query['number'].to_s
|
||||
|
||||
case query['action'].to_s
|
||||
when 'Validate'
|
||||
is_valid = LUHN.valid?(number)
|
||||
answer = number
|
||||
when 'Generate'
|
||||
digit = LUHN.generate(number)
|
||||
answer = "#{number}" + digit.to_s
|
||||
is_valid = ! digit.nil?
|
||||
end
|
||||
end
|
||||
|
||||
puts <<"EOT"
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Playing with LUHN checksums in Ruby
|
||||
</title>
|
||||
</head>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="500">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<h2>Playing with LUHN checksums in Ruby<br/>"mod 10 Double-Add-Double"</h2>
|
||||
<p>Enter an alpha-numeric string like a credit card number or International Securities Identification Number (ISO 6166).
|
||||
Click validate to test if the entered string is correct. Click generate to append the check digit to the string.
|
||||
</p>
|
||||
<form name="luhn" method="GET" action="index.rb">
|
||||
<textarea name="number" wrap="virtual" rows="2" cols="30">#{answer}</textarea>
|
||||
<br/><b>#{ is_valid ? "Is valid." : "Is NOT valid." }</b>
|
||||
<br/>
|
||||
<br/>
|
||||
<input type="submit" name="action" value="Validate">
|
||||
|
||||
<input type="submit" name="action" value="Generate">
|
||||
|
||||
<input type="button" value="Clear" onclick="this.form.number.value = ''">
|
||||
</form>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOT
|
||||
|
||||
exit(0)
|
||||
@@ -0,0 +1,80 @@
|
||||
#!@ruby_exe@
|
||||
|
||||
require 'cgi'
|
||||
require ENV['DOCUMENT_ROOT'] + '/test/ruby/LUHN'
|
||||
|
||||
if ENV['QUERY_STRING'].nil? then
|
||||
answer = ''
|
||||
numebr = ''
|
||||
else
|
||||
query = CGI.parse(ENV['QUERY_STRING'])
|
||||
number = query['number'].to_s
|
||||
|
||||
case query['action'].to_s
|
||||
when 'Validate'
|
||||
is_valid = LUHN.valid?(number)
|
||||
answer = number
|
||||
when 'Generate'
|
||||
digit = LUHN.generate(number)
|
||||
answer = "#{number}" + digit.to_s
|
||||
is_valid = ! digit.nil?
|
||||
end
|
||||
end
|
||||
|
||||
puts <<"EOT"
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Playing with LUHN checksums in Ruby
|
||||
</title>
|
||||
</head>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="500">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<h2>Playing with LUHN checksums in Ruby<br/>"mod 10 Double-Add-Double"</h2>
|
||||
<p>Enter an alpha-numeric string like a credit card number or International Securities Identification Number (ISO 6166).
|
||||
Click validate to test if the entered string is correct. Click generate to append the check digit to the string.
|
||||
</p>
|
||||
<form name="luhn" method="GET" action="index.rb">
|
||||
<textarea name="number" wrap="virtual" rows="2" cols="30">#{answer}</textarea>
|
||||
<br/><b>#{ is_valid ? "Is valid." : "Is NOT valid." }</b>
|
||||
<br/>
|
||||
<br/>
|
||||
<input type="submit" name="action" value="Validate">
|
||||
|
||||
<input type="submit" name="action" value="Generate">
|
||||
|
||||
<input type="button" value="Clear" onclick="this.form.number.value = ''">
|
||||
</form>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOT
|
||||
|
||||
exit(0)
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat <<'EOT'
|
||||
<table border="1" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Environment Variables</h3></caption>
|
||||
EOT
|
||||
|
||||
env | sed -e 's/^\(.[^\=]*\)=\(.*\)$/<tr><td class="normal">\1<\/td><td class="normal">\2\ <\/td><\/tr>/'
|
||||
|
||||
echo "</table>"
|
||||
|
||||
if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi
|
||||
if [[ $REQUEST_METHOD == "POST" && -n $CONTENT_LENGTH ]]; then
|
||||
STUFF=$(dd bs=1 count="$CONTENT_LENGTH" 2>/dev/null)
|
||||
COUNT=$(printf "%s" "$STUFF" | wc -c)
|
||||
|
||||
cat <<EOT
|
||||
<table border="1" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Standard Input</h3></caption>
|
||||
<tr><td class="normal"><pre>Length: $COUNT</pre></td></tr>
|
||||
<tr><td class="normal"><pre>$STUFF</pre></td></tr>
|
||||
</table>
|
||||
EOT
|
||||
|
||||
if [[ $CONTENT_LENGTH -eq $COUNT ]]; then
|
||||
echo "[ OK ] CONTENT_LENGTH = bytes read"
|
||||
else
|
||||
echo "[ BAD ] CONTENT_LENGTH != bytes read"
|
||||
fi
|
||||
|
||||
fi
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat <<'-EOT-'
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi/1.0 Shell Test 0 - Display Enviroment
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td class="normal">
|
||||
|
||||
<div align="center">
|
||||
<h3>Results from Simple GET request</h3>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Assertions</h3></caption>
|
||||
-EOT-
|
||||
|
||||
if [[ "$PATH" == '/usr/local/bin:/usr/bin:/bin' ]]; then
|
||||
|
||||
echo "<tr><td>[ OK ] PATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] PATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $ENV ]]; then
|
||||
echo "<tr><td>[ OK ] ENV</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] ENV</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $CDPATH ]]; then
|
||||
echo "<tr><td>[ OK ] CDPATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] CDPATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi
|
||||
if [[ $REQUEST_METHOD == 'GET' ]]; then
|
||||
echo "<tr><td>[ OK ] REQUEST_METHOD</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] REQUEST_METHOD</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $DOCUMENT_ROOT ]]; then
|
||||
echo "<tr><td>[ OK ] DOCUMENT_ROOT</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] DOCUMENT_ROOT</td></tr>"
|
||||
fi
|
||||
|
||||
# Test for existence only, since the location changes.
|
||||
if [[ -z $SCRIPT_FILENAME ]]; then
|
||||
echo "<tr><td>[ BAD ] SCRIPT_FILENAME</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ OK ] SCRIPT_FILENAME</td></tr>"
|
||||
fi
|
||||
|
||||
# Test for existence only, since the default value might change.
|
||||
if [[ -z $SERVER_PORT ]]; then
|
||||
echo "<tr><td>[ BAD ] SERVER_PORT</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ OK ] SERVER_PORT</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $SERVER_SOFTWARE ]]; then SERVER_SOFTWARE=''; fi
|
||||
if [[ $SERVER_SOFTWARE == 'hibachi/1.0' ]]; then
|
||||
echo "<tr><td>[ OK ] SERVER_SOFTWARE</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] SERVER_SOFTWARE</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $GATEWAY_INTERFACE ]]; then GATEWAY_INTERFACE=''; fi
|
||||
if [[ $GATEWAY_INTERFACE == 'CGI/0.0' ]]; then
|
||||
echo "<tr><td>[ OK ] GATEWAY_INTERFACE</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] GATEWAY_INTERFACE</td></tr>"
|
||||
fi
|
||||
|
||||
echo "</table>"
|
||||
|
||||
if [[ -z $DOCUMENT_ROOT ]]; then DOCUMENT_ROOT='.'; fi
|
||||
# We want to source the file, but for SC1091 the file is not available at the time of this edit.
|
||||
#
|
||||
# SC1091 (info): Not following: ./test/shell/dump.sh was not specified as input (see shellcheck -x).
|
||||
# https://www.shellcheck.net/wiki/SC1091
|
||||
# shellcheck disable=SC1091
|
||||
source "$DOCUMENT_ROOT/test/shell/dump.sh"
|
||||
|
||||
cat <<'-EOT-'
|
||||
<br>
|
||||
<form method="GET" action="test1.sh">
|
||||
<b>Next Test: <input type="submit" name="example" value="GET REQUEST WITH QUERY-STRING">
|
||||
<input type="hidden" name="garibaldi" value="peek-a-boo"></b>
|
||||
</form>
|
||||
</div>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
-EOT-
|
||||
|
||||
exit 0
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat <<'-EOT-'
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
Set-Cookie: cookie1=test1.sh; path=/
|
||||
Set-Cookie: cookie2=test1.sh; path=/
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi/1.0 Shell Test 1
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td class="normal">
|
||||
|
||||
<div align="center">
|
||||
<h2>Results of Form GET request</h2>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Assertions</h3></caption>
|
||||
-EOT-
|
||||
|
||||
if [[ $PATH == '/usr/local/bin:/usr/bin:/bin' ]]; then
|
||||
echo "<tr><td>[ OK ] PATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] PATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $ENV ]]; then
|
||||
echo "<tr><td>[ OK ] ENV</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] ENV</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $CDPATH ]]; then
|
||||
echo "<tr><td>[ OK ] CDPATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] CDPATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi
|
||||
if [[ $REQUEST_METHOD == 'GET' ]]; then
|
||||
echo "<tr><td>[ OK ] REQUEST_METHOD</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] REQUEST_METHOD</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $QUERY_STRING ]]; then QUERY_STRING=''; fi
|
||||
if [[ $QUERY_STRING == 'example=GET+REQUEST+WITH+QUERY-STRING&garibaldi=peek-a-boo' ]]; then
|
||||
echo "<tr><td>[ OK ] QUERY_STRING</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] QUERY_STRING</td></tr>"
|
||||
fi
|
||||
|
||||
echo "</table>"
|
||||
|
||||
if [[ -z $DOCUMENT_ROOT ]]; then DOCUMENT_ROOT='.'; fi
|
||||
# We want to source the file, but for SC1091 the file is not available at the time of this edit.
|
||||
#
|
||||
# SC1091 (info): Not following: ./test/shell/dump.sh was not specified as input (see shellcheck -x).
|
||||
# https://www.shellcheck.net/wiki/SC1091
|
||||
# shellcheck disable=SC1091
|
||||
source "$DOCUMENT_ROOT/test/shell/dump.sh"
|
||||
|
||||
cat <<'-EOT-'
|
||||
<br>
|
||||
<form method="POST" action="test2.sh">
|
||||
<b>Next Test:</b> <input type="submit" name="example" value="POST REQUEST WITH COOKIES">
|
||||
<input type="hidden" name="hibachi" value="is not Apache">
|
||||
<input type="hidden" name="garibaldi" value="peek-a-boo">
|
||||
</form>
|
||||
</div>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
-EOT-
|
||||
|
||||
exit 0
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat <<'-EOT-'
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi/1.0 Shell Test 2
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td class="normal">
|
||||
|
||||
<div align="center">
|
||||
<h2>Results of Form POST request</h2>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Assertions</h3></caption>
|
||||
-EOT-
|
||||
|
||||
if [[ "$PATH" = '/usr/local/bin:/usr/bin:/bin' ]]; then
|
||||
|
||||
echo "<tr><td>[ OK ] PATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] PATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z "$ENV" ]]; then
|
||||
echo "<tr><td>[ OK ] ENV</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] ENV</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z "$CDPATH" ]]; then
|
||||
echo "<tr><td>[ OK ] CDPATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] CDPATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi
|
||||
if [[ "$REQUEST_METHOD" = 'POST' ]]; then
|
||||
echo "<tr><td>[ OK ] REQUEST_METHOD</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] REQUEST_METHOD</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z "$QUERY_STRING" ]]; then
|
||||
echo "<tr><td>[ OK ] QUERY_STRING</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] QUERY_STRING</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $HTTP_COOKIE ]]; then HTTP_COOKIE=''; fi
|
||||
if [[ "$HTTP_COOKIE" == 'cookie1=test1.sh; cookie2=test1.sh' || "$HTTP_COOKIE" == 'cookie2=test1.sh; cookie1=test1.sh' ]]; then
|
||||
echo "<tr><td>[ OK ] HTTP_COOKIE</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] HTTP_COOKIE</td></tr>"
|
||||
fi
|
||||
|
||||
echo "</table>"
|
||||
|
||||
if [[ -z $DOCUMENT_ROOT ]]; then DOCUMENT_ROOT='.'; fi
|
||||
# We want to source the file, but for SC1091 the file is not available at the time of this edit.
|
||||
#
|
||||
# SC1091 (info): Not following: ./test/shell/dump.sh was not specified as input (see shellcheck -x).
|
||||
# https://www.shellcheck.net/wiki/SC1091
|
||||
# shellcheck disable=SC1091
|
||||
source "$DOCUMENT_ROOT/test/shell/dump.sh"
|
||||
|
||||
cat <<'-EOT-'
|
||||
</div>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
-EOT-
|
||||
|
||||
exit 0
|
||||
Reference in new issue
Block a user