Многие знают, что этот скрипт перестал поддерживаться разработчиками. Умельцы выложили раскодированный код файлов*, которые некогда были закодированы Ioncube:
Файл main.php
Файл tplutils.php
*файлы подходят для PHP 5.6
P.s раскодировано не мною, выложено в ознакомительных целях! Взято из открытых источников.
В целом, интересно услышать ваше мнение о HScript.
Файл main.php
PHP:
<?php
error_reporting(7);
define("HS2_BR", "<br />");
define("HS2_NL", "\r\n");
define("HS2_UNIX_SECOND", 1);
define("HS2_UNIX_MINUTE", 60);
define("HS2_UNIX_HOUR", 60 * HS2_UNIX_MINUTE);
define("HS2_UNIX_DAY", 24 * HS2_UNIX_HOUR);
global $_GS;
$_GS = array();
$_GS["info"] = array();
require_once "lib/sutils.php";
require_once "lib/mail.php";
$_GS["domain"] = preg_replace("|^(www\\.)|i", "", $_SERVER["SERVER_NAME"]);
$s = $_GS["domain"];
cutElemR($s, ".");
cutElemR($s, ".");
$_GS["subdomain"] = $s;
$s = $_SERVER["SCRIPT_NAME"];
$_GS["script"] = cutElemR($s, "/");
$_GS["root_dir"] = $s ? substr($s, 1) . "/" : "";
$s = $_GS["script"];
cutElemR($s, ".");
$_GS["module"] = strtolower($s);
$_GS["https"] = $_SERVER["SERVER_PORT"] == 443;
$_GS["root_url"] = getrooturl($_GS["https"]);
$s = $_SERVER["REQUEST_URI"];
cutElemL($s, "/" . $_GS["root_dir"]);
$_GS["uri"] = $s;
$_GS["server_ip"] = $_SERVER["SERVER_ADDR"];
$_GS["client_ip"] = $_SERVER["REMOTE_ADDR"];
$_GS["is_local"] = substr($_GS["server_ip"], 0, -1) == "127.0.0.";
$_GS["is_self"] = $_GS["client_ip"] == $_GS["server_ip"];
$_GS["lang"] = "";
$_GS["mode"] = "";
$_GS["theme"] = "";
$_GS["default_lang"] = "en";
$_GS["TZ"] = 0;
$_GS["site_name"] = "";
global $_IN;
$_IN = fromGPC($_POST);
if (1 < abs(chklic() - time())) {
exit;
}
function xAbort($message = "")
{
throw new Exception($message);
}
function xSysInfo($message, $type = 0)
{
$_GS["info"][$type][] = $message;
if ($type < 2) {
return NULL;
}
xAddToLog($message, "system");
if ($type == 2) {
xabort($message);
}
xStop($message);
}
function xSysWarning($message)
{
xsysinfo($message, 1);
}
function xSysError($message)
{
xsysinfo($message, 2);
}
function xSysStop($message, $and_refresh = false)
{
if ($and_refresh && !headers_sent()) {
refreshToURL(5);
}
xsysinfo($message, 3);
}
function xTerminal($is_debug = false)
{
global $_GS;
if ($is_debug) {
error_reporting(32767);
}
ob_implicit_flush();
header("Content-Type: text/plain; charset=\"utf-8\"");
header("Pragma: no-cache");
$_GS["as_term"] = true;
}
function xEcho()
{
global $_GS;
foreach (func_num_args() ? func_get_args() : array("- - - - -") as $message) {
if (is_array($message) || is_object($message)) {
$message = print_r($message, true);
}
$message .= HS2_NL;
if (!$_GS["as_term"]) {
$message = nl2br($message);
}
echo $message;
}
}
function xStop()
{
foreach (func_get_args() as $message) {
xecho($message);
}
exit;
}
function xAddToLog($message, $topic = "", $clear_before = false)
{
global $_GS;
$fname = "logs/log_" . $topic . ".txt";
if ($clear_before) {
unlink($fname);
}
clearstatcache();
$t = file_exists($fname) ? @filemtime($fname) : 0;
if ($f = fopen($fname, "a")) {
$d = abs(time() - $t);
if (10 <= $d) {
fwrite($f, "- - - - - [" . gmdate("d.m.y H:i:s") . ($d <= 120 ? " +" . $d : "") . "] - - - - -" . HS2_NL);
}
if (is_array($message) || is_object($message)) {
$message = print_r($message, true);
}
fwrite($f, "<" . $_GS["module"] . "> " . $message . HS2_NL);
fclose($f);
}
}
function getRootURL($as_HTTPS = false)
{
global $_GS;
return ($as_HTTPS ? "https" : "http") . "://" . $_GS["domain"] . "/" . $_GS["root_dir"];
}
function ss1Elem(&$s)
{
if (!is_array($s)) {
$s = stripslashes($s);
} else {
foreach ($s as $i => $v) {
ss1Elem($s[$i]);
}
}
}
function fromGPC($s)
{
if (!is_null($s)) {
if (get_magic_quotes_gpc()) {
ss1elem($s);
}
mTrim($s);
}
return $s;
}
function filterInput($s, $mask = "")
{
if (is_null($s) || !$mask) {
return $s;
}
if ($mask == "*") {
return strip_tags($s);
}
preg_match("/^" . $mask . "\$/", $s, $a);
return $a[0];
}
function _arr_val(&$arr, $p)
{
if (!isset($arr)) {
return NULL;
}
if (preg_match("/(.+)\\[(.*)\\]/", $p, $a)) {
return _arr_val($arr[$a[1]], $a[2]);
}
return $arr[$p];
}
function isset_IN($p = "btn")
{
global $_IN;
return !is_null(_arr_val($_IN, $p));
}
function _IN($p, $mask = "")
{
global $_IN;
return filterinput(_arr_val($_IN, $p), $mask);
}
function _COOKIE($p, $mask = "")
{
return isset($_COOKIE[$p]) ? filterinput(fromgpc($_COOKIE[$p]), $mask) : NULL;
}
function _GET($p, $mask = "")
{
return isset($_GET[$p]) ? filterinput(fromgpc($_GET[$p]), $mask) : NULL;
}
function _POST($p, $mask = "")
{
return isset($_POST[$p]) ? filterinput(fromgpc($_POST[$p]), $mask) : NULL;
}
function isset_RQ($p)
{
$_RQ = $_GET + $_POST;
return !is_null(_arr_val($_RQ, $p));
}
function _RQ($p, $mask = "")
{
$_RQ = $_GET + $_POST;
return filterinput(fromgpc(_arr_val($_RQ, $p)), $mask);
}
function _SESSION($p)
{
return isset($_SESSION[$p]) ? $_SESSION[$p] : NULL;
}
function _INN($p)
{
return intval(_in($p));
}
function _COOKIEN($p)
{
return intval($_COOKIE[$p]);
}
function _GETN($p)
{
return intval($_GET[$p]);
}
function _POSTN($p)
{
return intval($_POST[$p]);
}
function _RQN($p)
{
return intval(_rq($p));
}
function validMail($s)
{
$mask = "|^.+@.+\\..+\$|";
return preg_match($mask, textLow($s));
}
function validURL($s)
{
$mask = "|^https?:\\/\\/.+\\..+\$|i";
return preg_match($mask, textLow($s));
}
function getDomain($s)
{
$mask = "|^(?:https?:\\/\\/)?(?:www\\.)?([^\\/]+)|i";
preg_match($mask, textLow($s), $a);
return $a[1];
}
function validDomain($s)
{
return preg_match("|.+\\..+\$|", $s);
}
function valid_filename($f)
{
return !sEmpty($f) && $f != "." && $f != ".." && textPos("/", $f) < 0 && textPos(chr(0), $f) < 0;
}
function compare_ip($ip1, $ip2, $level = 4)
{
$ip1 = explode(".", $ip1);
$ip2 = explode(".", $ip2);
for ($i = 0; $i <= $level - 1; $i++) {
if ($ip1[$i] != $ip2[$i]) {
return false;
}
}
return true;
}
function numInRange($z, $a, $b)
{
return $a <= $z && $z <= $b;
}
function numRange($z, $a, $b)
{
if ($z < $a) {
$z = $a;
} else {
if ($b < $z) {
$z = $b;
}
}
return $z;
}
function calcPerc($sum, $perc, $r = 2)
{
return round($sum * $perc / 100, $r);
}
function idArrayCreate($arr, $fld = 0)
{
$res = array();
foreach ($arr as $r) {
$res[$r[$fld]] = $r;
}
return $res;
}
function idArrayFind($arr, $fld, $value)
{
foreach ($arr as $i => $r) {
if ($r[$fld] == $value) {
return $i;
}
}
}
function idArraySum($arr, $fld)
{
$z = 0;
foreach ($arr as $r) {
$z += $r[$fld];
}
return $z;
}
function asArray($a, $dlm = ",", $skip_empty = true)
{
if (is_array($a)) {
return $a;
}
$r = array();
foreach (explode($dlm, $a) as $v) {
$v = trim($v);
if (!$skip_empty || !sEmpty($v)) {
$r[] = $v;
}
}
return $r;
}
function asStr($s, $dlm = ",")
{
if (!is_array($s)) {
return $s;
}
return strval(@implode($dlm, $s));
}
function arrayToStr($a)
{
if (is_array($a)) {
return serialize($a);
}
return $a;
}
function strToArray($s)
{
if (is_array($a = @unserialize($s))) {
return $a;
}
return array();
}
function encodeArrayToStr($arr, $key)
{
return encode1(arraytostr($arr), $key, true, ord($key) % 8);
}
function decodeArrayFromStr($s, $key)
{
return strtoarray(decode1($s, $key, true, ord($key) % 8));
}
function fullURL($url = "*", $as_HTTPS = -1)
{
global $_GS;
$url = trim($url);
if ($url == "*") {
$url = $_GS["uri"];
} else {
$url = get1ElemL($url, "\n");
}
if (!validurl($url)) {
if ($as_HTTPS === -1) {
$as_HTTPS = $_GS["https"];
}
$url = getrooturl($as_HTTPS) . $url;
}
return $url;
}
function goToURL($url = "*", $work_after = 0)
{
if (1 < abs(chklic() - time())) {
exit;
}
$url = fullurl($url);
session_commit();
session_start();
session_regenerate_id();
header("Location: " . $url);
$work_after = intval($work_after);
if ($work_after < 1) {
exit;
}
@ignore_user_abort(1);
@set_time_limit($work_after);
header("Connection: close");
header("Content-Length: 0");
ob_end_clean();
ob_end_flush();
flush();
}
function refreshToURL($t = 0, $url = "*")
{
if ($t < 1) {
$t = 1;
}
$url = fullurl($url);
session_commit();
session_start();
session_regenerate_id();
header("Refresh: " . $t . "; URL=" . $url);
}
function timeToStamp($t = "*")
{
if ("" === $t) {
return "";
}
if ("*" === $t) {
$t = time();
}
return gmdate("YmdHis", $t);
}
function stampToTime($p)
{
if (empty($p)) {
return NULL;
}
$p = str_pad($p, 14, "0", STR_PAD_LEFT);
return @gmmktime(@substr($p, 8, 2), @substr($p, 10, 2), @substr($p, 12, 2), @substr($p, 4, 2), @substr($p, 6, 2), @substr($p, 0, 4));
}
function subStamps($p1, $p2 = -1)
{
$t1 = stamptotime($p1);
if ($p2 < 0) {
$t2 = $t1;
$t1 = time();
} else {
$t2 = stamptotime($p2);
}
return $t1 - $t2;
}
function encode1($text, $pass, $as_hex = true, $dl = 0)
{
$text = strval(base64_encode($text));
$pass = mb_strtoupper(md5($pass . mb_strlen($text)));
$code = "";
$n = $dl;
for ($i = 0; $i < mb_strlen($text); $i++) {
if (mb_strlen($pass) - $dl <= $n) {
$n = 0;
}
$c = ord($text[$i]) ^ ord($pass[$n]);
$code .= $as_hex ? sprintf("%02x", $c) : chr($c);
$n++;
}
if (!$as_hex) {
$code = base64_encode($code);
}
return $code;
}
function decode1($code, $pass, $as_hex = true, $dl = 0)
{
if (!$as_hex) {
$code = base64_decode($code);
}
$pass = mb_strtoupper(md5($pass . (mb_strlen($code) >> $as_hex)));
$text = "";
$n = $dl;
$i = 0;
while ($i < mb_strlen($code)) {
if (mb_strlen($pass) - $dl <= $n) {
$n = 0;
}
if ($as_hex) {
$c = hexdec(mb_substr($code, $i, 2));
} else {
$c = ord($code[$i]);
}
$text .= chr($c ^ ord($pass[$n]));
$n++;
$i += 1 + $as_hex;
}
return base64_decode($text);
}
function chkLic($n = 1)
{
global $_GS;
if (rand(1, $n) == 1) {
$l = trim(@file_get_contents($_GS["domain"] . ".lic"));
if ($l !== md5("?hhdn@\${aryhe)2273ru@1f/|" . $_GS["domain"])) {
xstop("No license");
}
}
return time();
}
?>
PHP:
<?php
require_once "smarty3/Smarty.class.php";
global $tpl_page;
global $tpl_errors;
$tpl_page = new Smarty();
$tpl_page->compile_check = true;
$tpl_page->caching = false;
$tpl_page->debugging = false;
$tpl_page->compile_dir = "tpl_c";
$tpl_page->template_dir = "tpl";
$tpl_errors = array();
require_once "lib/main.php";
if (1 < abs(chklic() - time())) {
exit;
}
global $_DF;
$_DF = array(array("% H:i", "* j, Y", "MDYHI", "m/d/y h:m", "m/d/y", "m" => array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), "f" => array("yesterday", "today", "tomorrow")));
$tpl_page->registerPlugin("function", "_getFormSecurity", "tplFormSecurity");
function existLang($lang)
{
if (sEmpty($lang) || $lang == "." || $lang == "..") {
return false;
}
return is_dir("tpl/" . $lang);
}
function getLang($lang = "")
{
global $_GS;
if ($lang == "") {
$lang = $_GS["lang"];
} else {
if ($lang == "*") {
$lang = $_GS["default_lang"];
}
}
if (existlang($lang)) {
return $lang;
}
return $_GS["default_lang"];
}
function getLangDir($lang = "")
{
global $_GS;
$dir = "tpl/";
foreach (array(getlang($lang), $_GS["mode"], $_GS["theme"]) as $d) {
if (sEmpty($d)) {
break;
}
if (is_dir($dir . $d)) {
$dir .= $d . "/";
} else {
break;
}
}
return $dir;
}
function prepVal(&$vl, $conv)
{
global $_GS;
if (!is_array($vl)) {
if ($conv & 1) {
$vl = textLangFilter($vl, $_GS["lang"]);
}
if ($conv & 2) {
$vl = htmlspecialchars($vl, ENT_QUOTES);
} else {
if ($conv & 4) {
$vl = strip_tags($vl);
}
}
} else {
foreach ($vl as $f => $v) {
prepVal($vl[$f], $conv);
}
}
}
function setPage($par, $val, $conv = 3)
{
global $tpl_page;
if (0 < $conv) {
prepval($val, $conv);
}
$tpl_page->assign($par, $val);
}
function showPage($templ = "", $module = false, $exit_after = true)
{
global $tpl_page;
global $tpl_errors;
global $_IN;
global $_GS;
global $_DF;
global $_cfg;
if ($module === false) {
$module = $_GS["module"];
}
setpage("tpl_module", $module);
setpage("tpl_vmodule", $_GS["vmodule"]);
if (file_exists($_GS["module_dir"] . $module . ".php")) {
$t = cutElemR($module, "/");
if (!$templ) {
$templ = $t;
}
} else {
if (!$templ) {
$templ = "index";
}
}
setpage("tpl_name", $templ);
$templ = $module . "/" . $templ;
setpage("tpl_filename", $templ);
loadDateFormat($lang);
setpage("InputDateFormatLong", trim($_DF[$lang][3]));
setpage("InputDateFormat", trim($_DF[$lang][4]));
setpage("tpl_time", time() + $_GS["TZ"]);
setpage("_IN", $_IN);
setpage("tpl_info", getInfoData("*"));
setpage("tpl_errors", $tpl_errors);
$tpl_page->template_dir = $_GS["lang_dir"];
if (1 < abs(chklic(5) - time())) {
exit;
}
if ($_cfg["Sys_ForceCharset"]) {
header("Content-Type: text/html; charset=utf-8");
}
$tpl_page->display($templ . ".tpl");
if ($exit_after) {
exit;
}
}
function showInfo($code = "Completed", $url = "*", $data = array())
{
$url = fullURL($url);
$_SESSION["_show_info"][$url] = array($code, $data);
goToURL($url);
}
function showSplash($code = "Completed", $url = "*", $data = array(), $templ = "splash", $tm = 0)
{
$url = fullURL($url);
$_SESSION["_show_info"][$url] = array($code, $data);
if ($tm < 1) {
$tm = substr($code, 0, 1) == "*" ? 3 : 1;
}
refreshToURL($tm, $url);
setpage("url", $url);
showpage($templ);
}
function showFormInfo($code = "Completed", $form = "", $data = array())
{
$_SESSION["_show_info"][getFormName($form)] = array($code, $data);
goToURL(fullURL());
}
function getInfoData($id = "", $and_unset = true)
{
$id = $id == "*" ? fullURL() : getFormName($id);
$info = $_SESSION["_show_info"][$id];
if ($and_unset) {
unset($_SESSION["_show_info"][$id]);
}
return $info;
}
function getFormName($form = "")
{
global $_GS;
if (!$form || is_int($form)) {
return $_GS["module"] . "_frm" . $form;
}
return $form;
}
function sendedForm($btn = "", $form = "")
{
global $_IN;
$form = getformname($form) . "_btn" . $btn;
if ($res = isset_IN($form)) {
}
unset($_IN[$form]);
return $res;
}
function setError($e, $form = "", $and_break = true)
{
if (!is_string($e)) {
return NULL;
}
global $tpl_errors;
$tpl_errors[getformname($form)][] = $e;
if ($and_break) {
xAbort($e);
}
}
function breakIfError($form = "", $e = "Error")
{
global $tpl_errors;
if (0 < count($tpl_errors[getformname($form)])) {
xAbort($e);
}
}
function loadText($section, $file = "texts", $lang = "")
{
$file = getlangdir($lang) . (string) $file . ".lng";
if (!file_exists($file)) {
return false;
}
$res = array();
$celem = "";
$is = false;
$h = fopen($file, "r");
while (!feof($h)) {
$s = trim(fgets($h, 4096));
if (substr($s, 0, 2) == "//") {
continue;
}
if (substr($s, 0, 1) == "[" && substr($s, -1) == "]") {
if ($is && textPos(".", $celem) < 0) {
break;
}
$celem = trim(substr($s, 1, -1));
$is = get1ElemL($celem, ".") == $section;
} else {
if ($is) {
$res[$celem] .= $s . HS2_NL;
}
}
}
fclose($h);
return $res;
}
function sendMailToUser($mail, $section, $consts = array(), $lang = "", $fname = "e-mails")
{
global $_GS;
global $_cfg;
if (!validMail($mail) || !$section) {
return false;
}
$lang = getlang($lang);
$txt = loadtext($section, $fname, $lang);
if (!$txt[(string) $section . ".message"]) {
return false;
}
$hdr = loadtext("_header", $fname, $lang);
$ftr = loadtext("_footer", $fname, $lang);
$consts["date"] = timeToStr(time(), 0, $lang);
$consts["ip"] = $_GS["client_ip"];
$consts["rooturl"] = $_GS["root_url"];
$consts["sitename"] = $_cfg["Sys_SiteName"];
prepval($consts, 2);
return sendMail($mail, textVarReplace($txt[(string) $section . ".topic"], $consts), textVarReplace($hdr["_header"] . $txt[(string) $section . ".message"] . $ftr["_footer"], $consts), $_cfg["Sys_NotifyMail"]);
}
function sendMailToAdmin($section, $consts = array())
{
global $_cfg;
return sendmailtouser($_cfg["Sys_AdminMail"], $section, $consts, $_cfg["Sys_AdminLang"], "admin/e-mails");
}
function loadDateFormat(&$lang)
{
global $_DF;
$lang = getlang($lang);
if (isset($_DF[$lang])) {
return NULL;
}
$df = getlangdir($lang) . "date.lng";
if (file_exists($df)) {
$a = @file($df);
$l1 = explode("|", $a[0], 5);
$l2 = explode("|", $a[1], 12);
$l3 = explode("|", $a[2], 6);
if (3 <= count($l1) && count($l2) == 12) {
$_DF[$lang] = $l1;
$_DF[$lang]["m"] = $l2;
$_DF[$lang]["f"] = $l3;
}
}
if (!isset($_DF[$lang])) {
$lang = 0;
}
}
function timeToStr($t, $format = 0, $lang = "", $tz = "")
{
if (!$t) {
return "";
}
global $_GS;
global $_DF;
loaddateformat($lang);
$s = "";
if ($tz === "") {
$tz = $_GS["TZ"];
}
$t += $tz;
$t0 = time() + $tz;
if ($format == 2) {
$n = floor((gmmktime(0, 0, 0, gmdate("n", $t), gmdate("j", $t), gmdate("Y", $t)) - gmmktime(0, 0, 0, gmdate("n", $t0), gmdate("j", $t0), gmdate("Y", $t0))) / HS2_UNIX_DAY);
$fc = floor(count($_DF[$lang]["f"]) / 2);
if (0 - $fc <= $n && $n <= $fc) {
$s = $_DF[$lang]["f"][$n + $fc];
}
}
if (!$s) {
$s = gmdate($_DF[$lang][1], $t);
$m = $_DF[$lang]["m"][-1 + gmdate("m", $t)];
$s = textReplace($s, "*", $m);
}
if ($format != 1) {
$s = textReplace(gmdate($_DF[$lang][0], $t), "%", $s);
}
return $s;
}
function textToTime($sd, $format = 0, $lang = "", $tz = "")
{
global $_GS;
global $_DF;
if (!$sd) {
return "";
}
foreach (array("/", "-", ":", " ", ",", ";") as $d) {
$sd = textReplace($sd, $d, ".");
}
$sd = textReplace($sd, "..", ".");
$d = explode(".", $sd, 5);
loaddateformat($lang);
$sd = textUp($_DF[$lang][2]);
$a = array(0, 0, 0, 0, 0);
foreach (array("Y", "M", "D", "H", "I") as $i => $c) {
$a[$i] = $d[@TextPos($c, $sd)];
}
if ($tz === "") {
$tz = $_GS["TZ"];
}
$t0 = time() + $tz;
if (3 <= textLen($d[0])) {
foreach ($_DF[$lang]["f"] as $n => $m) {
if (textPos(textUp($d[0]), textUp($m)) == 0) {
$t = $t0 + HS2_UNIX_DAY * ($n - floor(count($_DF[$lang]["f"]) / 2));
$a = array(gmdate("Y", $t), gmdate("n", $t), gmdate("j", $t), $d[1], $d[2]);
break;
}
}
}
if (!intval($a[2])) {
return "";
}
if (3 <= textLen($a[1])) {
foreach ($_DF[$lang]["m"] as $n => $m) {
if (textPos(textUp($a[1]), textUp($m)) == 0) {
$a[1] = $n + 1;
break;
}
}
}
if (0 < $format) {
$a[3] = 0;
$a[4] = 0;
}
if ($a[2] && !$a[0]) {
$a[0] = gmdate("Y", $t0);
if (!intval($a[1])) {
$a[1] = gmdate("n", $t0);
}
}
if ($t = gmmktime(intval($a[3]), intval($a[4]), 0, intval($a[1]), intval($a[2]), intval($a[0]))) {
if ($format == 2 && 0 < $t) {
$t += HS2_UNIX_DAY - 1;
}
$t -= $tz;
}
return $t;
}
function stampArrayToStr(&$a, $keys, $format = 2, $lang = "")
{
if (is_array($a) && $a) {
foreach (asArray($keys) as $k) {
$a[$k] = timetostr(stampToTime($a[$k]), $format, $lang);
}
}
}
function stampTableToStr(&$a, $keys, $format = 2, $lang = "")
{
if (is_array($a) && $a && ($keys = asArray($keys))) {
foreach ($a as $i => $r) {
stamparraytostr($a[$i], $keys, $format, $lang);
}
}
}
function strArrayToStamp(&$a, $keys, $format = 0, $lang = "")
{
if (is_array($a) && $a) {
foreach (asArray($keys) as $k) {
$a[$k] = timeToStamp(texttotime($a[$k], $format, $lang));
}
}
}
function getFormCert($form = "")
{
if (!isset($_SESSION)) {
return false;
}
$form = getformname($form);
$s = substr(md5(time() . rand()), 0, 8);
$_SESSION["_cert"][$form] = $s;
if (10 < count($_SESSION["_cert"])) {
array_shift($_SESSION["_cert"]);
}
return "<input name=\"__Cert\" value=\"" . $s . "\" type=\"hidden\">";
}
function chkFormCert($s, $form = "")
{
if (!isset($_SESSION) || !$s) {
return false;
}
$form = getformname($form);
if (!isset($_SESSION["_cert"][$form])) {
return false;
}
$res = $_SESSION["_cert"][$form] === $s;
unset($_SESSION["_cert"][$form]);
return $res;
}
function checkFormSecurity($form = "")
{
$form = getformname($form);
if (!chkformcert(_IN("__Cert"), $form)) {
xSysStop("Security: Wrong form certificate", true);
}
global $_IN;
unset($_IN["__Cert"]);
if (function_exists("chkCaptcha") && !chkCaptcha($form)) {
seterror("captcha_wrong", $form);
}
}
function tplFormSecurity($params, $tpl_page)
{
$form = getformname($params["form"]);
if (function_exists("getCaptcha")) {
$tpl_page->assign("__Capt", getCaptcha(0 + $params["captcha"], $form));
}
return getformcert($form);
}
?>
*файлы подходят для PHP 5.6
P.s раскодировано не мною, выложено в ознакомительных целях! Взято из открытых источников.
В целом, интересно услышать ваше мнение о HScript.