###TIMEOUT_ARCH;\r
\r
$time = time();\r
-print strftime("%d.%m.%Y %H:%M:%S", gmtime($time))."\n";\r
+print strftime('%d.%m.%Y %H:%M:%S', gmtime($time))."\n";\r
cleardir(ARCH_PATH);\r
\r
sub cleardir {\r
print "Failed to open: $dirpath\/\n";\r
return 0;\r
}\r
- while ($subpath = readdir $dir) {\r
+ while (defined($subpath = readdir $dir)) {\r
$subpathfull=$dirpath.$subpath;\r
if ($subpath =~ /^\.\.?$/) {\r
next;\r
my $contentlength;
- my @curl_arg=(CURL_PATH,'-i','-#'); # the command line arguments for curl
+ my @curl_arg=(CURL_PATH,'-i','-#','--compressed'); # the command line arguments for curl
my @reqhead; # the HTTP request header
my @resphead;
# All unlocking access must be logged: time, IP, user. The server owner must
# be able to know who did what with the proxy (in case of legal problems).
open ($logfile, ">>", UNLOCK_LOG) or return unlockpage("Couldn't log your action.","Status: 500 Internal Server Error\n");
- print $logfile strftime("%d.%m.%Y %H:%M:%S", gmtime($accesstime))." $IP $CGI{'username'}\n";
+ print $logfile strftime('%d.%m.%Y %H:%M:%S', gmtime($accesstime))." $IP $CGI{'username'}\n";
close($logfile);
# Ok, unlocked. Create access file.
use Exporter;\r
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);\r
\r
+use constant entitycode => {\r
+ 'amp' => '&',\r
+ 'gt' => '>',\r
+ 'lt' => '<',\r
+ 'quot' => '"',\r
+ 'acute' => '´',\r
+ 'cedil' => '¸',\r
+ 'circ' => 'ˆ',\r
+ 'macr' => '¯',\r
+ 'middot' => '·',\r
+ 'tilde' => '˜',\r
+ 'uml' => '¨',\r
+ 'Aacute' => 'Á',\r
+ 'aacute' => 'á',\r
+ 'Acirc' => 'Â',\r
+ 'acirc' => 'â',\r
+ 'AElig' => 'Æ',\r
+ 'aelig' => 'æ',\r
+ 'Agrave' => 'À',\r
+ 'agrave' => 'à',\r
+ 'Aring' => 'Å',\r
+ 'aring' => 'å',\r
+ 'Atilde' => 'Ã',\r
+ 'atilde' => 'ã',\r
+ 'Auml' => 'Ä',\r
+ 'auml' => 'ä',\r
+ 'Ccedil' => 'Ç',\r
+ 'ccedil' => 'ç',\r
+ 'Eacute' => 'É',\r
+ 'eacute' => 'é',\r
+ 'Ecirc' => 'Ê',\r
+ 'ecirc' => 'ê',\r
+ 'Egrave' => 'È',\r
+ 'egrave' => 'è',\r
+ 'ETH' => 'Ð',\r
+ 'eth' => 'ð',\r
+ 'Euml' => 'Ë',\r
+ 'euml' => 'ë',\r
+ 'Iacute' => 'Í',\r
+ 'iacute' => 'í',\r
+ 'Icirc' => 'Î',\r
+ 'icirc' => 'î',\r
+ 'Igrave' => 'Ì',\r
+ 'igrave' => 'ì',\r
+ 'Iuml' => 'Ï',\r
+ 'iuml' => 'ï',\r
+ 'Ntilde' => 'Ñ',\r
+ 'ntilde' => 'ñ',\r
+ 'Oacute' => 'Ó',\r
+ 'oacute' => 'ó',\r
+ 'Ocirc' => 'Ô',\r
+ 'ocirc' => 'ô',\r
+ 'OElig' => 'Œ',\r
+ 'oelig' => 'œ',\r
+ 'Ograve' => 'Ò',\r
+ 'ograve' => 'ò',\r
+ 'Oslash' => 'Ø',\r
+ 'oslash' => 'ø',\r
+ 'Otilde' => 'Õ',\r
+ 'otilde' => 'õ',\r
+ 'Ouml' => 'Ö',\r
+ 'ouml' => 'ö',\r
+ 'Scaron' => 'Š',\r
+ 'scaron' => 'š',\r
+ 'szlig' => 'ß',\r
+ 'THORN' => 'Þ',\r
+ 'thorn' => 'þ',\r
+ 'Uacute' => 'Ú',\r
+ 'uacute' => 'ú',\r
+ 'Ucirc' => 'Û',\r
+ 'ucirc' => 'û',\r
+ 'Ugrave' => 'Ù',\r
+ 'ugrave' => 'ù',\r
+ 'Uuml' => 'Ü',\r
+ 'uuml' => 'ü',\r
+ 'Yacute' => 'Ý',\r
+ 'yacute' => 'ý',\r
+ 'yuml' => 'ÿ',\r
+ 'Yuml' => 'Ÿ',\r
+ 'cent' => '¢',\r
+ 'curren' => '¤',\r
+ 'euro' => '€',\r
+ 'pound' => '£',\r
+ 'yen' => '¥',\r
+ 'brvbar' => '¦',\r
+ 'bull' => '•',\r
+ 'copy' => '©',\r
+ 'dagger' => '†',\r
+ 'Dagger' => '‡',\r
+ 'frasl' => '⁄',\r
+ 'hellip' => '…',\r
+ 'iexcl' => '¡',\r
+ 'image' => 'ℑ',\r
+ 'iquest' => '¿',\r
+ 'lrm' => '',\r
+ 'mdash' => '—',\r
+ 'ndash' => '–',\r
+ 'not' => '¬',\r
+ 'oline' => '‾',\r
+ 'ordf' => 'ª',\r
+ 'ordm' => 'º',\r
+ 'para' => '¶',\r
+ 'permil' => '‰',\r
+ 'prime' => '′',\r
+ 'Prime' => '″',\r
+ 'real' => 'ℜ',\r
+ 'reg' => '®',\r
+ 'rlm' => '',\r
+ 'sect' => '§',\r
+ 'shy' => '',\r
+ 'sup1' => '¹',\r
+ 'trade' => '™',\r
+ 'weierp' => '℘',\r
+ 'bdquo' => '„',\r
+ 'laquo' => '«',\r
+ 'ldquo' => '“',\r
+ 'lsaquo' => '‹',\r
+ 'lsquo' => '‘',\r
+ 'raquo' => '»',\r
+ 'rdquo' => '”',\r
+ 'rsaquo' => '›',\r
+ 'rsquo' => '’',\r
+ 'sbquo' => '‚',\r
+ 'emsp' => ' ',\r
+ 'ensp' => ' ',\r
+ 'nbsp' => ' ',\r
+ 'thinsp' => ' ',\r
+ 'zwj' => '',\r
+ 'zwnj' => '',\r
+ 'deg' => '°',\r
+ 'divide' => '÷',\r
+ 'frac12' => '½',\r
+ 'frac14' => '¼',\r
+ 'frac34' => '¾',\r
+ 'ge' => '≥',\r
+ 'le' => '≤',\r
+ 'minus' => '−',\r
+ 'sup2' => '²',\r
+ 'sup3' => '³',\r
+ 'times' => '×',\r
+ 'alefsym' => 'ℵ',\r
+ 'and' => '∧',\r
+ 'ang' => '∠',\r
+ 'asymp' => '≈',\r
+ 'cap' => '∩',\r
+ 'cong' => '≅',\r
+ 'cup' => '∪',\r
+ 'empty' => '∅',\r
+ 'equiv' => '≡',\r
+ 'exist' => '∃',\r
+ 'fnof' => 'ƒ',\r
+ 'forall' => '∀',\r
+ 'infin' => '∞',\r
+ 'int' => '∫',\r
+ 'isin' => '∈',\r
+ 'lang' => '⟨',\r
+ 'lceil' => '⌈',\r
+ 'lfloor' => '⌊',\r
+ 'lowast' => '∗',\r
+ 'micro' => 'µ',\r
+ 'nabla' => '∇',\r
+ 'ne' => '≠',\r
+ 'ni' => '∋',\r
+ 'notin' => '∉',\r
+ 'nsub' => '⊄',\r
+ 'oplus' => '⊕',\r
+ 'or' => '∨',\r
+ 'otimes' => '⊗',\r
+ 'part' => '∂',\r
+ 'perp' => '⊥',\r
+ 'plusmn' => '±',\r
+ 'prod' => '∏',\r
+ 'prop' => '∝',\r
+ 'radic' => '√',\r
+ 'rang' => '⟩',\r
+ 'rceil' => '⌉',\r
+ 'rfloor' => '⌋',\r
+ 'sdot' => '⋅',\r
+ 'sim' => '∼',\r
+ 'sub' => '⊂',\r
+ 'sube' => '⊆',\r
+ 'sum' => '∑',\r
+ 'sup' => '⊃',\r
+ 'supe' => '⊇',\r
+ 'there4' => '∴',\r
+ 'Alpha' => 'Α',\r
+ 'alpha' => 'α',\r
+ 'Beta' => 'Β',\r
+ 'beta' => 'β',\r
+ 'Chi' => 'Χ',\r
+ 'chi' => 'χ',\r
+ 'Delta' => 'Δ',\r
+ 'delta' => 'δ',\r
+ 'Epsilon' => 'Ε',\r
+ 'epsilon' => 'ε',\r
+ 'Eta' => 'Η',\r
+ 'eta' => 'η',\r
+ 'Gamma' => 'Γ',\r
+ 'gamma' => 'γ',\r
+ 'Iota' => 'Ι',\r
+ 'iota' => 'ι',\r
+ 'Kappa' => 'Κ',\r
+ 'kappa' => 'κ',\r
+ 'Lambda' => 'Λ',\r
+ 'lambda' => 'λ',\r
+ 'Mu' => 'Μ',\r
+ 'mu' => 'μ',\r
+ 'Nu' => 'Ν',\r
+ 'nu' => 'ν',\r
+ 'Omega' => 'Ω',\r
+ 'omega' => 'ω',\r
+ 'Omicron' => 'Ο',\r
+ 'omicron' => 'ο',\r
+ 'Phi' => 'Φ',\r
+ 'phi' => 'φ',\r
+ 'Pi' => 'Π',\r
+ 'pi' => 'π',\r
+ 'piv' => 'ϖ',\r
+ 'Psi' => 'Ψ',\r
+ 'psi' => 'ψ',\r
+ 'Rho' => 'Ρ',\r
+ 'rho' => 'ρ',\r
+ 'Sigma' => 'Σ',\r
+ 'sigma' => 'σ',\r
+ 'sigmaf' => 'ς',\r
+ 'Tau' => 'Τ',\r
+ 'tau' => 'τ',\r
+ 'Theta' => 'Θ',\r
+ 'theta' => 'θ',\r
+ 'thetasym' => 'ϑ',\r
+ 'upsih' => 'ϒ',\r
+ 'Upsilon' => 'Υ',\r
+ 'upsilon' => 'υ',\r
+ 'Xi' => 'Ξ',\r
+ 'xi' => 'ξ',\r
+ 'Zeta' => 'Ζ',\r
+ 'zeta' => 'ζ',\r
+ 'crarr' => '↵',\r
+ 'darr' => '↓',\r
+ 'dArr' => '⇓',\r
+ 'harr' => '↔',\r
+ 'hArr' => '⇔',\r
+ 'larr' => '←',\r
+ 'lArr' => '⇐',\r
+ 'rarr' => '→',\r
+ 'rArr' => '⇒',\r
+ 'uarr' => '↑',\r
+ 'uArr' => '⇑',\r
+ 'clubs' => '♣',\r
+ 'diams' => '♦',\r
+ 'hearts' => '♥',\r
+ 'spades' => '♠',\r
+ 'loz' => '◊',\r
+};\r
+\r
###ARCH_PATH;\r
###ACCESS_PATH;\r
###TIMEOUT_UNLOCK;\r
###TIMEOUT_INACT;\r
###UNLOCK_PROXY_HOST;\r
\r
-$VERSION = 0.000002;\r
+$VERSION = 0.000003;\r
@ISA = qw(Exporter);\r
@EXPORT = ();\r
-@EXPORT_OK = qw(access divideurl formatheader getcgi joinurl path2url url2path path2urldiv urldecode urldiv2path);\r
+@EXPORT_OK = qw(access divideurl entitydecode formatheader getcgi joinurl path2url url2path path2urldiv readconfigfile urldecode urldiv2path);\r
%EXPORT_TAGS = ();\r
\r
# This function checks if the user has unlocked the proxy. Nonzero means yes.\r
return $t;\r
}\r
\r
+sub entitydecode {\r
+ my $t = $_[0];\r
+ $t =~ s/&(#?[a-zA-Z0-9]+);/entitydecode1ch($1)/eg;\r
+ return $t;\r
+}\r
+\r
+sub entitydecode1ch {\r
+ my $t = $_[0];\r
+ if ($t =~ /^#([0-9]+)$/) {\r
+ return chr($1);\r
+ }\r
+ elsif ($t =~ /^#x([0-9A-Fa-f]+)$/) {\r
+ return chr(hex($1));\r
+ }\r
+ elsif ($t =~ /^([A-Za-z0-9]+)$/) {\r
+ return entitycode->{$1};\r
+ }\r
+ else {\r
+ return '';\r
+ }\r
+}\r
+\r
# The function to get CGI parameters from string.\r
# Format is: name=url_encoded_value&name=url_encoded_value& ... &name=url_encoded_value\r
sub getcgi {\r
return joinurl(path2urldiv($_[0]));\r
}\r
\r
+sub readconfigfile {\r
+ (my $configpath) = @_;\r
+ my $configfile;\r
+ my %config;\r
+ \r
+ if (open ($configfile, "<", $configpath)) {\r
+ while (defined(my $line = <$configfile>)) {\r
+ $line =~ s/[\r\n]//g;\r
+ $line =~ s/#.*$//;\r
+ if ($line =~ /^ *([a-zA-Z0-9_\-\.]+) *= *(.*)$/){\r
+ my $name=$1;\r
+ my $value=$2;\r
+ $value =~ s/ *$//;\r
+ $config{$name}=$value;\r
+ }\r
+ }\r
+ close ($configfile);\r
+ }\r
+ return %config;\r
+}\r
+\r
1;\r