CGI source code in ThatIsEz host

From CMEE4K
Jump to navigation Jump to search

Web root directory /var/www/html

The Apache root directory /var/www/html and phpinfo.php file

<?php
  phpinfo();
?>

Web cgi directory /var/www/cgi-bin

<?php
print "Using PHP language and execute as CGI code. This is '\$_SERVER' key array:\n";
print "<table style='text-align:left' border='1' cellpadding='1' cellspacing='0'>\n";
print "<tr><th>Var Name</th><th>Type</th><th>Value</th></tr>\n";
foreach( $_SERVER as $key => $value ) {
   print "<tr><td>$key</td><td>".gettype($value)."</td><td>$value</td></tr>\n";
}
print "</table>\n\n";
print "</body>\n</html>\n";
?>
#!/usr/bin/env perl
print "Content-type: text/html

<!DOCTYPE html><html><head><title>Perl CGI Env</title></head>
<body>
Using Perl language and execute as CGI code.   The is '\%ENV' hash.
<table style='text-align:left' border='1' cellpadding='1' cellspacing='0'>
<tr><td>Var Name</td><td>Value</td></tr>
";

foreach( sort keys( %ENV ) ) {
   next if m/^HASH/;
   print "<tr><td>$_</td><td>$ENV{$_}</td></tr>\n";
}
print "\n</table>\n</body>\n</html>\n";
exit 0;
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os
print('Content-Type: text/html; charset=utf-8\n')
print('<html><title>Python CGI code</title><body>\n');
print("Using Python language and execute as CGI code.  This is 'os.environ' hash.\n");
print("<table style='text-align:left' border='1' cellpadding='1' cellspacing='0'>\n");
print('<tr><th>Var Name</th><th>Type</th><th>Value</th></tr>\n');

for var in os.environ:
  value = os.environ.get(var);
  typeStr = str(value.__class__);
  typeStr = typeStr.replace( '<', '<' );
  typeStr = typeStr.replace( '>', '>' );
  print('<tr><td>'+var+'</td><td>'+typeStr+'</td><td>'+value+'</td></tr>\n');

print('</table></body></html>\n');

Web user directory /var/www/html/simon

  • hello.php PHP file in simon directory. The source code is same as above hello.php file.