Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- //require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
- //require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
- //$APPLICATION->SetTitle("cryptopro");
- require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/start.php");
- //require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/virtual_io.php");
- //require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/virtual_file.php");
- require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/mysql/user.php");
- require_once $_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/classes/general/main.php";
- $application = \Bitrix\Main\Application::getInstance();
- $application->initializeExtendedKernel(array(
- "get" => $_GET,
- "post" => $_POST,
- "files" => $_FILES,
- "cookie" => $_COOKIE,
- "server" => $_SERVER,
- "env" => $_ENV
- ));
- //define global application object
- $GLOBALS["APPLICATION"] = new CMain;
- if(defined("SITE_ID"))
- define("LANG", SITE_ID);
- if(defined("LANG") && false)
- {
- if(defined("ADMIN_SECTION") && ADMIN_SECTION===true)
- $db_lang = CLangAdmin::GetByID(LANG);
- else
- $db_lang = CLang::GetByID(LANG);
- $arLang = $db_lang->Fetch();
- if(!$arLang)
- {
- throw new \Bitrix\Main\SystemException("Incorrect site: ".LANG.".");
- }
- }
- else
- {
- //$arLang = $GLOBALS["APPLICATION"]->GetLang();
- define("LANG", 'ru');
- }
- $lang = $arLang["LID"];
- if (!defined("SITE_ID"))
- define("SITE_ID", $arLang["LID"]);
- define("SITE_DIR", $arLang["DIR"]);
- define("SITE_SERVER_NAME", $arLang["SERVER_NAME"]);
- define("SITE_CHARSET", $arLang["CHARSET"]);
- define("FORMAT_DATE", $arLang["FORMAT_DATE"]);
- define("FORMAT_DATETIME", $arLang["FORMAT_DATETIME"]);
- define("LANG_DIR", $arLang["DIR"]);
- define("LANG_CHARSET", $arLang["CHARSET"]);
- define("LANG_ADMIN_LID", $arLang["LANGUAGE_ID"]);
- define("LANGUAGE_ID", $arLang["LANGUAGE_ID"]);
- $GLOBALS["APPLICATION"] = new CMain;
- if(defined("SITE_ID"))
- define("LANG", SITE_ID);
- $GLOBALS["USER"] = new CUser;
- CMain::PrologActions();
- ?>
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>Подпись документа</title>
- </head>
- <body>
- <!-- <link href="https://fonts.googleapis.com/css?family=Comfortaa" rel="stylesheet">-->
- <? //CJSCore::Init(array("jquery"));?>
- <script language="javascript" src="https://code.jquery.com/jquery-1.8.3.min.js"></script>
- <script language="javascript" src="/cryptopro/cadesplugin_api.js"></script>
- <script language="javascript" src="/cryptopro/async_code.js"></script>
- <script language="javascript" src="/cryptopro/script.js"></script>
- <!-- <link href="https://fonts.googleapis.com/css?family=Neucha" rel="stylesheet">-->
- <style>
- body {
- font-family: Helvetica, Arial, sans-serif;
- font-weight: normal;
- }
- h2 {
- font-weight: normal;
- font-size: 18px;
- }
- p {
- font-size: 16px;
- }
- span {
- font-size: 16px;
- }
- #MyBtn
- {
- display: inline-block;
- white-space: nowrap;
- background-color: #ccc;
- background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#ccc));
- background-image: -webkit-linear-gradient(top, #eee, #ccc);
- background-image: -moz-linear-gradient(top, #eee, #ccc);
- background-image: -ms-linear-gradient(top, #eee, #ccc);
- background-image: -o-linear-gradient(top, #eee, #ccc);
- background-image: linear-gradient(top, #eee, #ccc);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#eeeeee', EndColorStr='#cccccc');
- border: 1px solid #777;
- padding: 0 1.5em;
- margin: 0.5em;
- font: bold 1em/2em Arial, Helvetica;
- text-decoration: none;
- color: #333;
- text-shadow: 0 1px 0 rgba(255,255,255,.8);
- -moz-border-radius: .2em;
- -webkit-border-radius: .2em;
- border-radius: .2em;
- -moz-box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
- -webkit-box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
- box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
- font-size: 13px;
- font-weight: 200;
- }
- #MyBtn:hover
- {
- background-color: #ddd;
- background-image: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#ddd));
- background-image: -webkit-linear-gradient(top, #fafafa, #ddd);
- background-image: -moz-linear-gradient(top, #fafafa, #ddd);
- background-image: -ms-linear-gradient(top, #fafafa, #ddd);
- background-image: -o-linear-gradient(top, #fafafa, #ddd);
- background-image: linear-gradient(top, #fafafa, #ddd);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#fafafa', EndColorStr='#dddddd');
- }
- #MyBtn:active
- {
- -moz-box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
- -webkit-box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
- box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
- position: relative;
- top: 1px;
- }
- #MyBtn:focus
- {
- outline: 0;
- background: #fafafa;
- }
- #MyBtn:before
- {
- background: #ccc;
- background: rgba(0,0,0,.1);
- float: left;
- width: 1em;
- text-align: center;
- font-size: 1.5em;
- margin: 0 1em 0 -1em;
- padding: 0 .2em;
- -moz-box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
- -webkit-box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
- box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
- -moz-border-radius: .15em 0 0 .15em;
- -webkit-border-radius: .15em 0 0 .15em;
- border-radius: .15em 0 0 .15em;
- }
- .container-my {
- background: #5FAC34;
- color: #fff;
- margin: 0 auto;
- margin-bottom: 10px;
- }
- .container-white-bg {
- background: #fff;
- color: black;
- }
- .info-top {
- height: 40px;
- }
- .page-body {
- height: 650px;
- }
- .icon {
- position: absolute;
- top: 8px;
- right: 8px;
- background: white;
- height:40px;
- }
- #my_file_name {
- color: #526A53;
- }
- .text-inside {
- padding-left: 10px;
- margin-right: 100px;
- }
- </style>
- <script>
- var splitByLastDot = function(text) {
- var index = text.lastIndexOf('.');
- return [text.slice(0, index)]
- }
- var glPATH, downloadLINK, downloadPDF, TOCKEN;
- $(function() {
- var postArray = {
- 'FILE_LINK': '<?=$_REQUEST['FILE_LINK']?>'
- };
- $.ajax({
- type: 'POST',
- data: postArray,
- url: '/cryptopro/download_file.php',
- success: function (data) {
- $('#my_file_name').text(data);
- glPATH = $('#my_file_path').text()+$('#my_file_name').text();
- // alert(glPATH);
- downloadLINK = '/cryptopro/'+$('#my_file_name').text();
- $('#OldFileLINK').attr("href", downloadLINK);
- $('#OldFileLINK').text('Скачать');
- // $("#OldFileTitle").css("display", "block");
- var myString = $("#my_file_name").text().split(".").pop();
- // alert(myString);
- if (myString != 'pdf') {
- downloadPDF = downloadLINK;
- // alert(splitByLastDot(downloadPDF));
- downloadPDF = splitByLastDot(downloadPDF)+'.pdf';
- // alert(downloadPDF);
- $('#PDFFileLINK').attr("href", downloadPDF);
- $('#PDFFileLINK').text('Скачать');
- // $("#PDFFileTitle").css("display", "block");
- }
- downloadLINK = '.' + downloadLINK.slice(10);
- $("#MyBtn").click(function () {
- var user, password;
- var reslink;
- user = $('#UserName').val();
- password = $('#UserPassword').val();
- var postArray = {
- 'USER_NAME': user,
- 'PASSWORD': password
- };
- $.ajax({
- type: 'POST',
- data: postArray,
- url: '/cryptopro/get_tocken.php',
- success: function (data) {
- // alert(data);
- var currentdate = new Date();
- TOCKEN = data;
- $('#UserName').attr('disabled', true);
- $('#UserPassword').attr('disabled', true);
- var fileNameMY;
- fileNameMY = $('#my_file_name').text();
- var postArray = {
- 'FILE_NAME' : fileNameMY,
- 'YEAR' : currentdate.getFullYear(),
- 'TOCKEN' : TOCKEN,
- 'USER_NAME' : user,
- 'PASSWORD' : password
- };
- $.ajax({
- type: 'POST',
- data: postArray,
- url: '/cryptopro/send_to_alfresco.php',
- success: function (data) {
- reslink = data;
- // alert('Всё готово, бегом проверять!');
- var postArray = {
- 'FILE_NAME' : fileNameMY
- };
- $.ajax({
- type: 'POST',
- data: postArray,
- url: '/cryptopro/delete_files.php',
- success: function () {
- window.open("http://10.1.4.11:8080/test/page/site/mpnas/document-details?nodeRef="+reslink, "_top");
- // alert('deleted');
- }
- });
- }
- });
- }
- });
- var postArray = {
- 'FILE_PATH': downloadLINK
- };
- $.ajax({
- type: 'POST',
- data: postArray,
- url: '/cryptopro/base64-file.php',
- success: function (data) {
- // alert('base64');
- $("#DataToSignTxtBox").text(data);
- Common_SignCadesBES('CertListBox');
- }
- });
- fileName = $('#my_file_name').text();
- fileName = splitByLastDot(fileName)+'.pdf';
- // alert(fileName);
- var currentdate = new Date();
- var datetime = "Время подписи: " + currentdate.getDate() + "/"
- + (currentdate.getMonth()+1) + "/"
- + currentdate.getFullYear() + " @ "
- + currentdate.getHours() + ":"
- + currentdate.getMinutes() + ":"
- + currentdate.getSeconds();
- var watertext = $( "#CertListBox option:selected" ).text() + '\\n' + datetime;
- var postArray = {
- 'FILE_NAME' : fileName,
- 'TEXT' : watertext
- };
- $.ajax({
- type: 'POST',
- data: postArray,
- url: '/cryptopro/fpdf_ru_test.php',
- success: function () {
- $('#PDFsignFileLINK').attr("href", '/cryptopro/signed-'+fileName);
- $('#PDFsignFileLINK').text('Скачать');
- // $("#PDFsignFileTitle").css("display", "block");
- }
- });
- });
- }
- });
- });
- </script>
- <div class="container-my info-top">
- <div class="text-inside" style="
- padding-top: 10px;">
- <!-- <h2>Проверка подключения плагина</h2>-->
- <b id="PlugInEnabledTxt">Плагин не загружен</b>
- <img src="/cryptopro/content.png" alt="Информация" class="icon">
- <img src="Img/red_dot.png" width="10" height="10" alt="Плагин не загружен" id="PluginEnabledImg"
- style="display: none;"/>
- <br>
- <span id="PlugInVersionTxt" lang="ru"> </span>
- <span id="CSPVersionTxt" lang="ru"> </span>
- <br>
- <span id="CSPNameTxt" lang="ru"> </span>
- </div>
- </div>
- <div class="container-my page-body container-white-bg">
- <div class="text-inside">
- <!--<h2>Файлы для подписи:</h2>
- <select size="3" name="FileListBox" id="FileListBox" style="resize:none;border:0;">
- <option value="./files/originals/pdf-sample.pdf">pdf-sample.pdf</option>
- <option value="./files/originals/pdf-test.pdf">pdf-test.pdf</option>
- </select>-->
- <h2>Имя файла:</h2>
- <b id="my_file_name">Скачивание файла на сервер...</b>
- <h2 style="display: none;">Путь:</h2>
- <p id="my_file_path" style="display: none;"><?='/var/www/html/cryptopro/'?></p>
- <h2>Ваши сертификаты:</h2>
- <select size="3" name="CertListBox" id="CertListBox" style="resize:none;border:0; margin-bottom: 20px;"></select>
- <div id="cert_info" style="display:none">
- <h2>Информация о сертификате</h2>
- <p class="info_field" id="subject"></p>
- <p class="info_field" id="issuer"></p>
- <p class="info_field" id="from"></p>
- <p class="info_field" id="till"></p>
- <p class="info_field" id="provname"></p>
- <p class="info_field" id="algorithm"></p>
- </div>
- <h2 id="info_msg" style="display: none;">Данные для подписи:</h2>
- <textarea id="DataToSignTxtBox" name="DataToSignTxtBox"
- style="height:20px;width:80%;resize:none;border:0; display: none !important;">Hello World</textarea>
- <br>
- <!-- <input id="SignBtn" type="button" value="Подписать" name="SignData" onclick="Common_SignCadesBES('CertListBox');">-->
- <div>
- <input id="UserName" placeholder="Логин" style="height: 20px;">
- <input id="UserPassword" type="password" placeholder="Пароль" style="height: 20px;">
- <input id="MyBtn" type="button" value="Подписать">
- </div>
- <!-- <h2>Загрузить файл:</h2>
- <input id="openFileButton" type="file" onchange="openFile(event)" style="width:300px;">
- <br>
- <input type="button" value="Подписать файл" onclick="
- if ('' == openFileButton.value)
- { alert('Файл не выбран.'); return; }
- else
- if ('' == fileContent || undefined == fileContent)
- { alert('Выбран пустой файл'); return; }
- else
- Common_SignCadesBES_File('CertListBox')">-->
- <h2 id="SignatureTitle" name="SignatureTitle" style="display: none !important;">Статус подписи</h2>
- <h2 id="OldFileTitle" name="OldFileLink" style="display: none !important;">Ссылка на файл: <a href=""
- id="OldFileLINK"
- download></a>
- </h2>
- <h2 id="PDFFileTitle" name="PDFFileLink" style="display: none !important;">Ссылка на PDF: <a href=""
- id="PDFFileLINK"
- download></a>
- </h2>
- <h2 id="PDFsignFileTitle" name="PDFsignFileLink" style="display: none !important;">Ссылка на подписанный PDF: <a href=""
- id="PDFsignFileLINK"
- download></a>
- </h2>
- <h2 id="SignatureFileTitle" name="SignatureFileLink" style="display: none !important;">Ссылка на подпись: <a
- href="" id="SignatureFileLINK" download></a></h2>
- <textarea id="SignatureTxtBox"
- style="font-size:9pt;height:300px;width:80%;resize:none;border:0; display: none !important;"></textarea>
- <!-- <h2 id="info_msg" name="TimeTitle">Время выполнения: </h2>-->
- </div>
- </div>
- </body>
- </html>
- <!--11111-->
- <!-- <div id="left-col">
- <div id="info">
- <img id="info_img" src="Img/application_information.png" alt="">
- <div id="info_msg" style="text-align:center;">
- <span id="PlugInEnabledTxt">Плагин загружен.</span>
- <img src="Img/green_dot.png" width="10" height="10" alt="Плагин не загружен" id="PluginEnabledImg">
- <br>
- <span id="PlugInVersionTxt" lang="ru">Версия плагина: 2.0.12711</span>
- <span id="CSPVersionTxt" lang="ru">Версия криптопровайдера: 4.0.9842</span>
- <br>
- <span id="CSPNameTxt" lang="ru">Криптопровайдер: Crypto-Pro GOST R 34.10-2001 Cryptographic Service Provider</span>
- </div>
- <div id="boxdiv" style="display:none">
- <span id="errorarea">
- У вас отсутствуют личные сертификаты. Вы можете
- <a href="#" onclick="Common_RetrieveCertificate();" style="color:#0837ff"> получить</a>
- сертификат от тестового УЦ, предварительно установив
- <a href="/certsrv/certnew.cer?ReqID=CACert&Enc=bin" style="color:#0837ff">корневой сертификат тестового УЦ</a>
- в доверенные.
- </span>
- </div>
- </div>
- <p id="info_msg" name="CertificateTitle">Сертификат:</p>
- <div id="item_border" name="CertListBoxToHide">
- <select size="4" name="CertListBox" id="CertListBox" style="width:100%;resize:none;border:0;">
- </select>
- </div>
- <div id="cert_info" style="display:none">
- <h2>Информация о сертификате</h2>
- <p class="info_field" id="subject"></p>
- <p class="info_field" id="issuer"></p>
- <p class="info_field" id="from"></p>
- <p class="info_field" id="till"></p>
- <p class="info_field" id="provname"></p>
- <p class="info_field" id="algorithm"></p>
- </div>
- <p id="info_msg">Загрузить файл:</p>
- <div id="item_border">
- <input id="openFileButton" type="file" onchange="openFile(event)" style="width:100%">
- <script>
- var openFile = function (event) {
- fileContent = undefined;
- var input = event.target;
- var reader = new FileReader();
- reader.readAsDataURL(input.files[0]);
- reader.onload = function () {
- var header = ";base64,";
- var fileData = reader.result;
- fileContent = fileData.substr(fileData.indexOf(header) + header.length);
- };
- };
- </script>
- </div>
- <p></p>
- <div>
- <input type="button" value="Подписать файл" onclick="
- if ('' == openFileButton.value)
- { alert('Файл не выбран.'); return; }
- else
- if ('' == fileContent || undefined == fileContent)
- { alert('Выбран пустой файл'); return; }
- else
- Common_SignCadesBES_File('CertListBox')">
- </div>
- <p id="info_msg" name="SignatureTitle">Подпись:</p>
- <div id="item_border">
- <textarea id="SignatureTxtBox" style="font-size:9pt;height:600px;width:100%;resize:none;border:0;"></textarea>
- <script language="javascript">
- var txtDataToSign = "Hello World";
- document.getElementById("SignatureTxtBox").innerHTML = "";
- var canPromise = !!window.Promise;
- if(canPromise) {
- cadesplugin.then(function () {
- Common_CheckForPlugIn();
- },
- function(error) {
- document.getElementById('PluginEnabledImg').setAttribute("src", "Img/red_dot.png");
- document.getElementById('PlugInEnabledTxt').innerHTML = error;
- }
- );
- } else {
- window.addEventListener("message", function (event){
- if (event.data == "cadesplugin_loaded") {
- CheckForPlugIn_NPAPI();
- } else if(event.data == "cadesplugin_load_error") {
- document.getElementById('PluginEnabledImg').setAttribute("src", "Img/red_dot.png");
- document.getElementById('PlugInEnabledTxt').innerHTML = "Плагин не загружен";
- }
- },
- false);
- window.postMessage("cadesplugin_echo_request", "*");
- }
- </script>
- </div>
- <p></p>
- <p id="info_msg" name="TimeTitle">Время выполнения: </p>
- </div>-->
- <!--11111-->
- <!---->
- <?
- global $APPLICATION;
- $r = $APPLICATION->EndBufferContentMan();
- \Bitrix\Main\Context::getCurrent()->getResponse()->flush($r);
- //require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
- //require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
Add Comment
Please, Sign In to add comment