chr(195) . chr(169),
"e!" => chr(195) . chr(168),
"u:" => chr(195) . chr(188),
"a:" => chr(195) . chr(164),
"a!" => chr(195) . chr(160),
"e:" => chr(195) . chr(171),
"o:" => chr(195) . chr(182),
"c," => chr(195) . chr(167),
"o'" => chr(195) . chr(179),
"i'" => chr(195) . chr(173),
"e>" => chr(195) . chr(170),
"a>" => chr(195) . chr(162),
"i:" => chr(195) . chr(175),
"a'" => chr(195) . chr(161),
">>" => chr(194) . chr(187),
"<<" => chr(194) . chr(171),
"o>" => chr(195) . chr(180),
"E'" => chr(195) . chr(137),
"i>" => chr(195) . chr(174),
"<(" => chr(91),
"//" => chr(92),
")>" => chr(93),
"'>" => chr(94),
"(!" => chr(123),
"!!" => chr(124),
"!)" => chr(125),
"'?" => chr(126),
"NS" => chr(194) . chr(160),
"!I" => chr(194) . chr(161),
"Ct" => chr(194) . chr(162),
"Pd" => chr(194) . chr(163),
"Cu" => chr(194) . chr(164),
"Ye" => chr(194) . chr(165),
"BB" => chr(194) . chr(166),
"SE" => chr(194) . chr(167),
"':" => chr(194) . chr(168),
"Co" => chr(194) . chr(169),
"-a" => chr(194) . chr(170),
"NO" => chr(194) . chr(172),
"--" => chr(194) . chr(173),
"Rg" => chr(194) . chr(174),
"'m" => chr(194) . chr(175),
"DG" => chr(194) . chr(176),
"+-" => chr(194) . chr(177),
"2S" => chr(194) . chr(178),
"3S" => chr(194) . chr(179),
"''" => chr(194) . chr(180),
"My" => chr(194) . chr(181),
"PI" => chr(194) . chr(182),
".M" => chr(194) . chr(183),
"'," => chr(194) . chr(184),
"1S" => chr(194) . chr(185),
"-o" => chr(194) . chr(186),
"14" => chr(194) . chr(188),
"12" => chr(194) . chr(189),
"34" => chr(194) . chr(190),
"?I" => chr(194) . chr(191),
"A!" => chr(195) . chr(128),
"A'" => chr(195) . chr(129),
"A>" => chr(195) . chr(130),
"A?" => chr(195) . chr(131),
"A:" => chr(195) . chr(132),
"AA" => chr(195) . chr(133),
"AE" => chr(195) . chr(134),
"C," => chr(195) . chr(135),
"E!" => chr(195) . chr(136),
"E>" => chr(195) . chr(138),
"E:" => chr(195) . chr(139),
"I!" => chr(195) . chr(140),
"I'" => chr(195) . chr(141),
"I>" => chr(195) . chr(142),
"I:" => chr(195) . chr(143),
"D-" => chr(195) . chr(144),
"N?" => chr(195) . chr(145),
"O!" => chr(195) . chr(146),
"O'" => chr(195) . chr(147),
"O>" => chr(195) . chr(148),
"O?" => chr(195) . chr(149),
"O:" => chr(195) . chr(150),
"*X" => chr(195) . chr(151),
"O/" => chr(195) . chr(152),
"U!" => chr(195) . chr(153),
"U'" => chr(195) . chr(154),
"U>" => chr(195) . chr(155),
"U:" => chr(195) . chr(156),
"Y'" => chr(195) . chr(157),
"TH" => chr(195) . chr(158),
"ss" => chr(195) . chr(159),
"a?" => chr(195) . chr(163),
"aa" => chr(195) . chr(165),
"ae" => chr(195) . chr(166),
"i!" => chr(195) . chr(172),
"d-" => chr(195) . chr(176),
"n?" => chr(195) . chr(177),
"o!" => chr(195) . chr(178),
"o?" => chr(195) . chr(181),
"-:" => chr(195) . chr(183),
"o/" => chr(195) . chr(184),
"u!" => chr(195) . chr(185),
"u'" => chr(195) . chr(186),
"u>" => chr(195) . chr(187),
"y'" => chr(195) . chr(189),
"th" => chr(195) . chr(190),
"s," => chr(195) . chr(186),
"y:" => chr(195) . chr(191));
function translate_mnemo($matches) {
global $CharArray;
$key = $matches[1];
$value = $CharArray[$key] ?? "";
if ($value !== "") {
return $value;
}
return $CharArray[strrev($key)] ?? "\\$key";
}
;
function translate_hexdec($matches) {
$num = hexdec($matches[1]);
$value = mb_chr($num);
if ($value !== FALSE) {
return $value;
}
return "";
}
function mnemo($string) {
$ld = chr(194) . chr(171);
$rd = chr(194) . chr(187);
$count1 = 0;
$count2 = 0;
if (strpos($string, "<<") !== FALSE) {
$string = preg_replace('/<<([a-fA-F0-9]+)>>/', "&x$1;", $string, -1, $count1);
}
if (strpos($string, $ld) !== FALSE) {
$string = preg_replace('/' . $ld . '([a-fA-F0-9]+)' . $rd .'/', "&x$1;", $string, -1, $count2);
}
$count = $count1 + $count2;
if ($count>0 || strpos($string, "&x") !== FALSE) {
$count = 0;
$string = preg_replace_callback('/&x([a-fA-F0-9]+);/', "translate_hexdec", $string, -1, $count);
}
if ($count>0 || strpos($string, "&") !== FALSE) {
$string = html_entity_decode($string, ENT_HTML5);
}
if (strpos($string, "\\") !== FALSE) {
$string = preg_replace_callback('/\\\(..)/', "translate_mnemo", $string);
}
return normalizer_normalize($string,Normalizer::FORM_C);
}
}
if (!function_exists("openJSON")) {
function openJSON($command="", $out="pipe") {
if ($command == "") {
$command="/usr/bin/mjson";
};
if ($out == "pipe") {
$outarray = array("pipe", "w");
}
else {
$outarray = array("file", "$out", "a");
}
$descriptors = array(
0 => array("pipe", "r"),
1 => $outarray,
);
$process = proc_open($command, $descriptors, $pipes, '/library/tmp', NULL);
if (is_resource($process)) {
$return = array("resource" => $process, "pipes" => $pipes);
}
else {
$return = NULL;
}
return $return;
}
}
if (!function_exists("submitJSON")) {
function submitJSON($pipes, $type, $json=NULL) {
if ($type == 'set') {
fwrite($pipes[0], $json . "\n");
}
}
}
// Open pipes to the M-environment
// Arguments: command: opening command
// out: stdout = pipe | filename
// Returns array ("resource" => process-resource,
// "pipes" => array of file pointers that correspond to PHP's end of any pipes that are created
// )
// or null if failure
if (!function_exists("openM")) {
function openM($command="", $out="pipe") {
if ($command == "") {
$command="mweb";
};
if ($out == "pipe") {
$outarray = array("pipe", "w");
}
else {
$out = tempnam("/library/tmp" . "/" . "html", "html.");
if (dirname($out) != dirname("/library/tmp" . "/" . "html" . "/". "x")) {
mkdir("/library/tmp" . "/" . "html");
$out = tempnam("/library/tmp" . "/" . "html", "html.");
}
$outarray = fopen($out, "wb");
}
$descriptors = array(
0 => array("pipe", "r"),
1 => $outarray,
);
$process = proc_open($command, $descriptors, $pipes, '/library/tmp', NULL);
if (is_resource($process)) {
$return = array("resource" => $process, "pipes" => $pipes, "out" => $out);
}
else {
$return = NULL;
}
return $return;
}
// Execute in M-environment
// Arguments: pipes = file pointers as obtained from openM
// commands = array with numerical indexes and M-commands as values
function execM($result, $commands=NULL) {
$pipes = $result["pipes"];
if ($commands !== NULL) {reset($commands);}
foreach ($commands as $command) {
fwrite($pipes[0], $command);
}
}
// Submit form-variables to M-environment
// Arguments: pipes = file pointers as obtained from openM
// type = start: start upload variables. Execute once before 'sets'.
// set : set variables
// end : end upload variables. Execute once after all 'sets'.
// commands = array with M-variable name as index, M-variable value as value if type == 'set'
function submitM($result, $type, $commands=NULL, $byJSON=TRUE) {
$pipes = $result["pipes"];
if ($commands !== NULL) {reset($commands);}
if ($type == 'start' && !$byJSON) {
fwrite($pipes[0], "\n");
}
if ($type == 'set') {
if (!$byJSON) {
foreach ($commands as $lvalue => $rvalue) {
$clvalue = transformL($lvalue);
$crvalue = transformR($rvalue);
fwrite($pipes[0], "");
fwrite($pipes[0], $clvalue);
fwrite($pipes[0], "\n");
fwrite($pipes[0], "");
fwrite($pipes[0], $crvalue);
fwrite($pipes[0], "\n");
}
}
if ($byJSON) {
$vars = array();
foreach ($commands as $lvalue => $rvalue) {
$clvalue = transformL($lvalue);
$crvalue = transformR($rvalue);
$vars[$clvalue] = $crvalue;
}
fwrite($pipes[0], json_encode($vars));
}
}
if ($type == 'end') {
if (!$byJSON) {
fwrite($pipes[0], "\n");
};
if ($byJSON) {
fwrite($pipes[0], "\n");
};
}
}
// Read from M-environment and send to stdout
// Arguments: pipes = file pointers as obtained from openM
// compress = FALSE | 0 : no compression
// size : compression if content > size
function readM($result, $compress=FALSE, $debug=FALSE ) {
$pipes = $result["pipes"];
if ($result["out"] != "pipe") {
closeM($result);
$out = $result["out"];
if ("1"==="1") {
$data = file_get_contents($out);
if (!mb_check_encoding($data, "UTF-8") && strpos($data, "") === false) {
$target = "/library/process/sweep" . DIRECTORY_SEPARATOR . "invalidUTF8" . DIRECTORY_SEPARATOR . basename($out);
file_put_contents($target, $data);
};
};
$body = file_get_contents($out);
// unlink($out); // comment if you want the raw HTML files in /library/tmp/html
$halt = ResponseCode(substr($body, 0, 128));
if ($halt === -1) {
exit();
}
if ($halt === 0) {
print $body;
return;
}
print substr($body, $halt);
return;
}
else {
$body = stream_get_contents($pipes[1]);
closeM($result);
$halt = ResponseCode(substr($body, 0, 128));
if ($halt === -1) {
exit();
}
if ($halt === 0) {
print $body;
return;
}
print substr($body, $halt);
return;
}
}
// Read from M-environment and returns
// Arguments: pipes = file pointers as obtained from openM
// compress = FALSE | 0 : no compression
// size : compression if content > size
function catchM($result) {
$pipes = $result["pipes"];
if ($result["out"] != "pipe") {
closeM($result);
$out = $result["out"];
$content = file_get_contents($out);
unlink($out);
}
else {
$content = stream_get_contents($pipes[1]);
closeM($result);
}
return $content;
}
// Close the M-environment
// Arguments: $result as obtained from openM
//
function closeM($result) {
$pipes = $result["pipes"];
$process = $result["resource"];
if ($pipes[0]) {
fclose($pipes[0]);
}
if ($pipes[1]) {
fclose($pipes[1]);
}
if ($process) {
proc_close($process);
}
}
}
if (!function_exists("errors")) {
function errors($lvalue, $rvalue) {
$errors = FALSE;
if (strpos($lvalue, "_") === 0) {
$errors = TRUE;
}
// if not $errors and (strpos($lvalue, "FD") != 0 and strpos($lvalue, "_") !== FALSE) {
// $errors = TRUE;
// }
return $errors;
}
}
if (!function_exists("transformL")) {
function transformL($lvalue) {
if (strpos($lvalue, "_") !== FALSE) {
$lvalue = preg_replace('/_([^_]*)/', ',"\\1"', $lvalue);
$lvalue = preg_replace('/(.*?),(.*)/', '\\1(\\2)', $lvalue);
}
return $lvalue;
}
}
if (!function_exists("transformR")) {
function transformR($rvalue) {
// $rvalue = preg_replace('/[\000-\011]|[\013-\014]|[\016-\037]|[\0177-\0237]/', '', $rvalue);
$rvalue = mnemo($rvalue);
return $rvalue;
}
}
if (!function_exists("LogData")) {
function LogData($logfile, $intro, $msg) {
if ($logfile !== "") {
$logfile = "/library/tmp" . DIRECTORY_SEPARATOR . $logfile;
$fp = fopen($logfile, 'a');
fwrite($fp, "\n");
if ($intro === "") {
fwrite($fp, "%%%%%%%%%%% New Submit %%%%%%%%%%%\n\n");
fclose($fp);
return;
}
fwrite($fp, "# $intro:\n");
fwrite($fp, "[".$msg."]");
fwrite($fp, "\n################\n");
fclose($fp);
}
}
}
if (!function_exists("ResponseCode")) {
function ResponseCode($str) {
$rsc = '[Response Status Code';
//LogData("response.log", "", "");
//LogData("response.log", "mode", "2");
//LogData("response.log", "test", $str);
$k = strpos($str, $rsc);
if (strpos($str, $rsc) !== FALSE) {
$rest = substr($str,$k);
//LogData("response.log", "found", $rest);
preg_match('/(?P\D*)(?P\d+)(?P.*)/', $rest, $matches);
$code = $matches['code'];
//LogData("response.log", "code", $code);
http_response_code(intval($code));
header('X-PHP-Response-Code: ' . $code, true, intval($code));
//var_dump(headers_list());
//exit();
$k = strpos($str, "<", $k);
if ($k==-1) {
return -1;
};
//LogData("response.log", "offset", strval($k));
//LogData("response.log", "rest", "[".substr($str, $k)."]");
return $k;
};
return 0;
}
}
$UDhttpua = $_SERVER["HTTP_USER_AGENT"];
$robot = isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider|curl|wget/i', $UDhttpua);
$uri = $_REQUEST["q"];
$debug_file = "/library/tmp" . DIRECTORY_SEPARATOR . "robotlink.txt";
$debug = file_exists($debug_file);
if ($debug) {
$log = << $UDhttpua,
"UDip" => $_SERVER["REMOTE_ADDR"],
"UDrobot" => "$robot",
"RDsent" => $sentinel,
"UDbrwsid" => $UDbrwsid,
"UDuri" => $uri,
"UDhttps" => $UDhttps,
"UDrou" => "%Entry^rlnsboot");
$M = openM();
submitM($M, "start");
submitM($M, "set", $postvars);
submitM($M, "end");
$send = catchM($M);
if ($debug) {
file_put_contents($debug_file, "\n\n\n$send\n\n\n", FILE_APPEND);
}
if (preg_match('/^URL:/', $send)) {
$url = preg_replace('/^URL:/', "", $send);
$url = trim($url);
if ($url[0] == "/") {
if ($_SERVER["HTTPS"] == "on") $url = "https:" . $url;
else $url = "http:" . $url;
};
header("Location: " . $url, true, 301);
die();
}
if (preg_match('/^404/', $send)) {
header("HTTP/1.0 404 Not Found");
die();
}
echo $send;
// file_put_contents('/library/tmp/mj.txt', "$send\n", FILE_APPEND);
exit;
?>