echo "ERR|" . Implode("|", $arErrors); } else { if ($res) { echo "FIN|" . $arTs["ts"] . "|" . $arTs["StatNum"]; } else { echo "STP|" . $arTs["Completed"] . "|" . $arTs["ts"] . "|" . $arTs["StartPoint"] . "|" . $arTs["StatNum"]; } } } elseif ($_REQUEST["fcajax"] == "vf") { if (!$RIGHT_VERIFY) { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } if (IntVal($_REQUEST["tm"]) < 5) { $_REQUEST["tm"] = 5; } $collector = new CFileChecker(); $arTs = array("ts" => IntVal($_REQUEST["ts"]), "Completed" => IntVal($_REQUEST["completed"]), "StartPoint" => $_REQUEST["startpoint"], "MaxExecutionTime" => IntVal($_REQUEST["tm"])); $arErrors = array(); $res = $collector->VerifyCrc(IntVal($_REQUEST["df"]), $_REQUEST["pwd"], $arTs, $arErrors); if (Count($arErrors) > 0) { echo "ERR|" . Implode("|", $arErrors); } else { if ($res) { echo "FIN|"; $fl = new CFileCheckerErrorLog(); $fl->Open(); $i = 0; while ($s = $fl->ReadLine()) { if ($i > 300) { echo GetMessage("MFC1_EXISTS_OTHER_DIF"); break;
function Verify($fileName, $pwdString, &$keyString, &$arErrors) { $fileName = Trim($fileName); if (StrLen($fileName) <= 0) { $arErrors[] = GetMessage("MFC1_FILE_NOT_SET") . ". "; return false; } $pwdString = Trim($pwdString); if (StrLen($pwdString) <= 0) { $arErrors[] = GetMessage("MFC1_PWD_NOT_SET") . ". "; return false; } $fileString = CFileCheckerUtil::GetFileContents($fileName); if (StrLen($fileString) <= 0) { $arErrors[] = GetMessage("MFC1_EMPTY_FILE") . ". "; return false; } if (preg_match("#<" . "\\?[\\s]*define\\(\"BX_INTEGRITY_VALUE\",[\\s]*'([^']*?)'\\);?[\\s]*\\?" . ">#i", $fileString, $arMatches)) { $data = $arMatches[1]; if (StrLen($data) > 0) { $fileString = preg_replace("#<" . "\\?[\\s]*define\\(\"BX_INTEGRITY_VALUE\",[\\s]*'[^']*?'\\);?[\\s]*\\?" . ">#i", "", $fileString); $currentCRC = sprintf("%u", crc32($fileString)); if ($arIntegrityParams = CFileCheckerSubscriber::__GetIntegrityParams($data, $pwdString)) { if ($arIntegrityParams["CRC"] != $currentCRC) { $arErrors[] .= GetMessage("MFC1_CRC_NOT_CORRECT") . ". "; return false; } else { $keyString = $arIntegrityParams["KEY"]; $keyString = CFileCheckerUtil::decrypt($keyString, CFileChecker::getIntegrityKey()); return true; } } else { $arErrors[] .= GetMessage("MFC1_NO_CRC") . ". "; return false; } } else { $arErrors[] .= GetMessage("MFC1_NO_CRC") . ". "; return false; } } else { $arErrors[] .= GetMessage("MFC1_NO_CRC_NOT_SET") . ". "; return false; } return false; }