Guest User

Untitled

a guest
Jun 13th, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.27 KB | None | 0 0
  1. <?
  2. //require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
  3. //require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
  4. //$APPLICATION->SetTitle("cryptopro");
  5. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/start.php");
  6.  
  7. //require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/virtual_io.php");
  8. //require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/virtual_file.php");
  9. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/mysql/user.php");
  10. require_once $_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/classes/general/main.php";
  11. $application = \Bitrix\Main\Application::getInstance();
  12.  
  13. $application->initializeExtendedKernel(array(
  14. "get" => $_GET,
  15. "post" => $_POST,
  16. "files" => $_FILES,
  17. "cookie" => $_COOKIE,
  18. "server" => $_SERVER,
  19. "env" => $_ENV
  20. ));
  21.  
  22. //define global application object
  23. $GLOBALS["APPLICATION"] = new CMain;
  24.  
  25. if(defined("SITE_ID"))
  26. define("LANG", SITE_ID);
  27.  
  28. if(defined("LANG") && false)
  29. {
  30. if(defined("ADMIN_SECTION") && ADMIN_SECTION===true)
  31. $db_lang = CLangAdmin::GetByID(LANG);
  32. else
  33. $db_lang = CLang::GetByID(LANG);
  34.  
  35. $arLang = $db_lang->Fetch();
  36.  
  37. if(!$arLang)
  38. {
  39. throw new \Bitrix\Main\SystemException("Incorrect site: ".LANG.".");
  40. }
  41. }
  42. else
  43. {
  44. //$arLang = $GLOBALS["APPLICATION"]->GetLang();
  45. define("LANG", 'ru');
  46. }
  47.  
  48. $lang = $arLang["LID"];
  49. if (!defined("SITE_ID"))
  50. define("SITE_ID", $arLang["LID"]);
  51. define("SITE_DIR", $arLang["DIR"]);
  52. define("SITE_SERVER_NAME", $arLang["SERVER_NAME"]);
  53. define("SITE_CHARSET", $arLang["CHARSET"]);
  54. define("FORMAT_DATE", $arLang["FORMAT_DATE"]);
  55. define("FORMAT_DATETIME", $arLang["FORMAT_DATETIME"]);
  56. define("LANG_DIR", $arLang["DIR"]);
  57. define("LANG_CHARSET", $arLang["CHARSET"]);
  58. define("LANG_ADMIN_LID", $arLang["LANGUAGE_ID"]);
  59. define("LANGUAGE_ID", $arLang["LANGUAGE_ID"]);
  60. $GLOBALS["APPLICATION"] = new CMain;
  61.  
  62. if(defined("SITE_ID"))
  63. define("LANG", SITE_ID);
  64. $GLOBALS["USER"] = new CUser;
  65.  
  66. CMain::PrologActions();
  67.  
  68. ?>
  69.  
  70. <!DOCTYPE HTML>
  71.  
  72. <html>
  73.  
  74. <head>
  75. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  76. <title>Подпись документа</title>
  77. </head>
  78.  
  79. <body>
  80.  
  81. <!-- <link href="https://fonts.googleapis.com/css?family=Comfortaa" rel="stylesheet">-->
  82.  
  83. <? //CJSCore::Init(array("jquery"));?>
  84. <script language="javascript" src="https://code.jquery.com/jquery-1.8.3.min.js"></script>
  85. <script language="javascript" src="/cryptopro/cadesplugin_api.js"></script>
  86. <script language="javascript" src="/cryptopro/async_code.js"></script>
  87. <script language="javascript" src="/cryptopro/script.js"></script>
  88. <!-- <link href="https://fonts.googleapis.com/css?family=Neucha" rel="stylesheet">-->
  89. <style>
  90. body {
  91. font-family: Helvetica, Arial, sans-serif;
  92. font-weight: normal;
  93. }
  94. h2 {
  95. font-weight: normal;
  96. font-size: 18px;
  97. }
  98.  
  99. p {
  100. font-size: 16px;
  101. }
  102.  
  103. span {
  104. font-size: 16px;
  105. }
  106.  
  107. #MyBtn
  108. {
  109. display: inline-block;
  110. white-space: nowrap;
  111. background-color: #ccc;
  112. background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#ccc));
  113. background-image: -webkit-linear-gradient(top, #eee, #ccc);
  114. background-image: -moz-linear-gradient(top, #eee, #ccc);
  115. background-image: -ms-linear-gradient(top, #eee, #ccc);
  116. background-image: -o-linear-gradient(top, #eee, #ccc);
  117. background-image: linear-gradient(top, #eee, #ccc);
  118. filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#eeeeee', EndColorStr='#cccccc');
  119. border: 1px solid #777;
  120. padding: 0 1.5em;
  121. margin: 0.5em;
  122. font: bold 1em/2em Arial, Helvetica;
  123. text-decoration: none;
  124. color: #333;
  125. text-shadow: 0 1px 0 rgba(255,255,255,.8);
  126. -moz-border-radius: .2em;
  127. -webkit-border-radius: .2em;
  128. border-radius: .2em;
  129. -moz-box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
  130. -webkit-box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
  131. box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
  132. font-size: 13px;
  133. font-weight: 200;
  134. }
  135.  
  136. #MyBtn:hover
  137. {
  138. background-color: #ddd;
  139. background-image: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#ddd));
  140. background-image: -webkit-linear-gradient(top, #fafafa, #ddd);
  141. background-image: -moz-linear-gradient(top, #fafafa, #ddd);
  142. background-image: -ms-linear-gradient(top, #fafafa, #ddd);
  143. background-image: -o-linear-gradient(top, #fafafa, #ddd);
  144. background-image: linear-gradient(top, #fafafa, #ddd);
  145. filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#fafafa', EndColorStr='#dddddd');
  146. }
  147.  
  148. #MyBtn:active
  149. {
  150. -moz-box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
  151. -webkit-box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
  152. box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
  153. position: relative;
  154. top: 1px;
  155. }
  156.  
  157. #MyBtn:focus
  158. {
  159. outline: 0;
  160. background: #fafafa;
  161. }
  162.  
  163. #MyBtn:before
  164. {
  165. background: #ccc;
  166. background: rgba(0,0,0,.1);
  167. float: left;
  168. width: 1em;
  169. text-align: center;
  170. font-size: 1.5em;
  171. margin: 0 1em 0 -1em;
  172. padding: 0 .2em;
  173. -moz-box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
  174. -webkit-box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
  175. box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
  176. -moz-border-radius: .15em 0 0 .15em;
  177. -webkit-border-radius: .15em 0 0 .15em;
  178. border-radius: .15em 0 0 .15em;
  179. }
  180.  
  181. .container-my {
  182. background: #5FAC34;
  183. color: #fff;
  184. margin: 0 auto;
  185. margin-bottom: 10px;
  186. }
  187. .container-white-bg {
  188. background: #fff;
  189. color: black;
  190. }
  191.  
  192. .info-top {
  193. height: 40px;
  194. }
  195.  
  196. .page-body {
  197. height: 650px;
  198. }
  199.  
  200. .icon {
  201. position: absolute;
  202. top: 8px;
  203. right: 8px;
  204. background: white;
  205. height:40px;
  206. }
  207.  
  208. #my_file_name {
  209. color: #526A53;
  210. }
  211.  
  212. .text-inside {
  213. padding-left: 10px;
  214. margin-right: 100px;
  215. }
  216. </style>
  217. <script>
  218. var splitByLastDot = function(text) {
  219. var index = text.lastIndexOf('.');
  220. return [text.slice(0, index)]
  221. }
  222. var glPATH, downloadLINK, downloadPDF, TOCKEN;
  223. $(function() {
  224. var postArray = {
  225. 'FILE_LINK': '<?=$_REQUEST['FILE_LINK']?>'
  226. };
  227. $.ajax({
  228. type: 'POST',
  229. data: postArray,
  230. url: '/cryptopro/download_file.php',
  231. success: function (data) {
  232. $('#my_file_name').text(data);
  233. glPATH = $('#my_file_path').text()+$('#my_file_name').text();
  234. // alert(glPATH);
  235. downloadLINK = '/cryptopro/'+$('#my_file_name').text();
  236. $('#OldFileLINK').attr("href", downloadLINK);
  237. $('#OldFileLINK').text('Скачать');
  238. // $("#OldFileTitle").css("display", "block");
  239.  
  240. var myString = $("#my_file_name").text().split(".").pop();
  241. // alert(myString);
  242. if (myString != 'pdf') {
  243. downloadPDF = downloadLINK;
  244. // alert(splitByLastDot(downloadPDF));
  245. downloadPDF = splitByLastDot(downloadPDF)+'.pdf';
  246. // alert(downloadPDF);
  247. $('#PDFFileLINK').attr("href", downloadPDF);
  248. $('#PDFFileLINK').text('Скачать');
  249. // $("#PDFFileTitle").css("display", "block");
  250. }
  251. downloadLINK = '.' + downloadLINK.slice(10);
  252.  
  253.  
  254. $("#MyBtn").click(function () {
  255. var user, password;
  256. var reslink;
  257. user = $('#UserName').val();
  258. password = $('#UserPassword').val();
  259. var postArray = {
  260. 'USER_NAME': user,
  261. 'PASSWORD': password
  262.  
  263. };
  264. $.ajax({
  265. type: 'POST',
  266. data: postArray,
  267. url: '/cryptopro/get_tocken.php',
  268. success: function (data) {
  269. // alert(data);
  270. var currentdate = new Date();
  271. TOCKEN = data;
  272. $('#UserName').attr('disabled', true);
  273. $('#UserPassword').attr('disabled', true);
  274. var fileNameMY;
  275. fileNameMY = $('#my_file_name').text();
  276. var postArray = {
  277. 'FILE_NAME' : fileNameMY,
  278. 'YEAR' : currentdate.getFullYear(),
  279. 'TOCKEN' : TOCKEN,
  280. 'USER_NAME' : user,
  281. 'PASSWORD' : password
  282. };
  283. $.ajax({
  284. type: 'POST',
  285. data: postArray,
  286. url: '/cryptopro/send_to_alfresco.php',
  287. success: function (data) {
  288. reslink = data;
  289. // alert('Всё готово, бегом проверять!');
  290. var postArray = {
  291. 'FILE_NAME' : fileNameMY
  292. };
  293. $.ajax({
  294. type: 'POST',
  295. data: postArray,
  296. url: '/cryptopro/delete_files.php',
  297. success: function () {
  298. window.open("http://10.1.4.11:8080/test/page/site/mpnas/document-details?nodeRef="+reslink, "_top");
  299. // alert('deleted');
  300.  
  301. }
  302. });
  303. }
  304. });
  305.  
  306. }
  307. });
  308. var postArray = {
  309. 'FILE_PATH': downloadLINK
  310. };
  311. $.ajax({
  312. type: 'POST',
  313. data: postArray,
  314. url: '/cryptopro/base64-file.php',
  315. success: function (data) {
  316. // alert('base64');
  317. $("#DataToSignTxtBox").text(data);
  318. Common_SignCadesBES('CertListBox');
  319. }
  320. });
  321. fileName = $('#my_file_name').text();
  322. fileName = splitByLastDot(fileName)+'.pdf';
  323. // alert(fileName);
  324. var currentdate = new Date();
  325. var datetime = "Время подписи: " + currentdate.getDate() + "/"
  326. + (currentdate.getMonth()+1) + "/"
  327. + currentdate.getFullYear() + " @ "
  328. + currentdate.getHours() + ":"
  329. + currentdate.getMinutes() + ":"
  330. + currentdate.getSeconds();
  331.  
  332. var watertext = $( "#CertListBox option:selected" ).text() + '\\n' + datetime;
  333.  
  334. var postArray = {
  335. 'FILE_NAME' : fileName,
  336. 'TEXT' : watertext
  337. };
  338. $.ajax({
  339. type: 'POST',
  340. data: postArray,
  341. url: '/cryptopro/fpdf_ru_test.php',
  342. success: function () {
  343. $('#PDFsignFileLINK').attr("href", '/cryptopro/signed-'+fileName);
  344. $('#PDFsignFileLINK').text('Скачать');
  345. // $("#PDFsignFileTitle").css("display", "block");
  346. }
  347. });
  348. });
  349. }
  350. });
  351. });
  352. </script>
  353.  
  354. <div class="container-my info-top">
  355. <div class="text-inside" style="
  356. padding-top: 10px;">
  357. <!-- <h2>Проверка подключения плагина</h2>-->
  358. <b id="PlugInEnabledTxt">Плагин не загружен</b>
  359. <img src="/cryptopro/content.png" alt="Информация" class="icon">
  360. <img src="Img/red_dot.png" width="10" height="10" alt="Плагин не загружен" id="PluginEnabledImg"
  361. style="display: none;"/>
  362. <br>
  363. <span id="PlugInVersionTxt" lang="ru"> </span>
  364. <span id="CSPVersionTxt" lang="ru"> </span>
  365. <br>
  366. <span id="CSPNameTxt" lang="ru"> </span>
  367. </div>
  368. </div>
  369.  
  370. <div class="container-my page-body container-white-bg">
  371. <div class="text-inside">
  372. <!--<h2>Файлы для подписи:</h2>
  373. <select size="3" name="FileListBox" id="FileListBox" style="resize:none;border:0;">
  374. <option value="./files/originals/pdf-sample.pdf">pdf-sample.pdf</option>
  375. <option value="./files/originals/pdf-test.pdf">pdf-test.pdf</option>
  376. </select>-->
  377. <h2>Имя файла:</h2>
  378. <b id="my_file_name">Скачивание файла на сервер...</b>
  379. <h2 style="display: none;">Путь:</h2>
  380. <p id="my_file_path" style="display: none;"><?='/var/www/html/cryptopro/'?></p>
  381. <h2>Ваши сертификаты:</h2>
  382. <select size="3" name="CertListBox" id="CertListBox" style="resize:none;border:0; margin-bottom: 20px;"></select>
  383. <div id="cert_info" style="display:none">
  384. <h2>Информация о сертификате</h2>
  385. <p class="info_field" id="subject"></p>
  386. <p class="info_field" id="issuer"></p>
  387. <p class="info_field" id="from"></p>
  388. <p class="info_field" id="till"></p>
  389. <p class="info_field" id="provname"></p>
  390. <p class="info_field" id="algorithm"></p>
  391. </div>
  392. <h2 id="info_msg" style="display: none;">Данные для подписи:</h2>
  393. <textarea id="DataToSignTxtBox" name="DataToSignTxtBox"
  394. style="height:20px;width:80%;resize:none;border:0; display: none !important;">Hello World</textarea>
  395.  
  396. <br>
  397. <!-- <input id="SignBtn" type="button" value="Подписать" name="SignData" onclick="Common_SignCadesBES('CertListBox');">-->
  398. <div>
  399. <input id="UserName" placeholder="Логин" style="height: 20px;">
  400. <input id="UserPassword" type="password" placeholder="Пароль" style="height: 20px;">
  401. <input id="MyBtn" type="button" value="Подписать">
  402. </div>
  403. <!-- <h2>Загрузить файл:</h2>
  404. <input id="openFileButton" type="file" onchange="openFile(event)" style="width:300px;">
  405. <br>
  406. <input type="button" value="Подписать файл" onclick="
  407. if ('' == openFileButton.value)
  408. { alert('Файл не выбран.'); return; }
  409. else
  410. if ('' == fileContent || undefined == fileContent)
  411. { alert('Выбран пустой файл'); return; }
  412. else
  413. Common_SignCadesBES_File('CertListBox')">-->
  414. <h2 id="SignatureTitle" name="SignatureTitle" style="display: none !important;">Статус подписи</h2>
  415. <h2 id="OldFileTitle" name="OldFileLink" style="display: none !important;">Ссылка на файл: <a href=""
  416. id="OldFileLINK"
  417. download></a>
  418. </h2>
  419. <h2 id="PDFFileTitle" name="PDFFileLink" style="display: none !important;">Ссылка на PDF: <a href=""
  420. id="PDFFileLINK"
  421. download></a>
  422. </h2>
  423. <h2 id="PDFsignFileTitle" name="PDFsignFileLink" style="display: none !important;">Ссылка на подписанный PDF: <a href=""
  424. id="PDFsignFileLINK"
  425. download></a>
  426. </h2>
  427. <h2 id="SignatureFileTitle" name="SignatureFileLink" style="display: none !important;">Ссылка на подпись: <a
  428. href="" id="SignatureFileLINK" download></a></h2>
  429. <textarea id="SignatureTxtBox"
  430. style="font-size:9pt;height:300px;width:80%;resize:none;border:0; display: none !important;"></textarea>
  431. <!-- <h2 id="info_msg" name="TimeTitle">Время выполнения: </h2>-->
  432. </div>
  433. </div>
  434.  
  435. </body>
  436. </html>
  437.  
  438. <!--11111-->
  439. <!-- <div id="left-col">
  440. <div id="info">
  441. <img id="info_img" src="Img/application_information.png" alt="">
  442. <div id="info_msg" style="text-align:center;">
  443. <span id="PlugInEnabledTxt">Плагин загружен.</span>
  444. <img src="Img/green_dot.png" width="10" height="10" alt="Плагин не загружен" id="PluginEnabledImg">
  445. <br>
  446. <span id="PlugInVersionTxt" lang="ru">Версия плагина: 2.0.12711</span>
  447. <span id="CSPVersionTxt" lang="ru">Версия криптопровайдера: 4.0.9842</span>
  448. <br>
  449. <span id="CSPNameTxt" lang="ru">Криптопровайдер: Crypto-Pro GOST R 34.10-2001 Cryptographic Service Provider</span>
  450. </div>
  451. <div id="boxdiv" style="display:none">
  452. <span id="errorarea">
  453. У вас отсутствуют личные сертификаты. Вы можете
  454. <a href="#" onclick="Common_RetrieveCertificate();" style="color:#0837ff"> получить</a>
  455. сертификат от тестового УЦ, предварительно установив
  456. <a href="/certsrv/certnew.cer?ReqID=CACert&amp;Enc=bin" style="color:#0837ff">корневой сертификат тестового УЦ</a>
  457. в доверенные.
  458. </span>
  459. </div>
  460. </div>
  461. <p id="info_msg" name="CertificateTitle">Сертификат:</p>
  462. <div id="item_border" name="CertListBoxToHide">
  463. <select size="4" name="CertListBox" id="CertListBox" style="width:100%;resize:none;border:0;">
  464. </select>
  465. </div>
  466.  
  467. <div id="cert_info" style="display:none">
  468. <h2>Информация о сертификате</h2>
  469. <p class="info_field" id="subject"></p>
  470. <p class="info_field" id="issuer"></p>
  471. <p class="info_field" id="from"></p>
  472. <p class="info_field" id="till"></p>
  473. <p class="info_field" id="provname"></p>
  474. <p class="info_field" id="algorithm"></p>
  475. </div>
  476.  
  477. <p id="info_msg">Загрузить файл:</p>
  478. <div id="item_border">
  479. <input id="openFileButton" type="file" onchange="openFile(event)" style="width:100%">
  480. <script>
  481. var openFile = function (event) {
  482. fileContent = undefined;
  483. var input = event.target;
  484. var reader = new FileReader();
  485. reader.readAsDataURL(input.files[0]);
  486. reader.onload = function () {
  487. var header = ";base64,";
  488. var fileData = reader.result;
  489. fileContent = fileData.substr(fileData.indexOf(header) + header.length);
  490. };
  491. };
  492. </script>
  493. </div>
  494. <p></p>
  495. <div>
  496. <input type="button" value="Подписать файл" onclick="
  497. if ('' == openFileButton.value)
  498. { alert('Файл не выбран.'); return; }
  499. else
  500. if ('' == fileContent || undefined == fileContent)
  501. { alert('Выбран пустой файл'); return; }
  502. else
  503. Common_SignCadesBES_File('CertListBox')">
  504. </div>
  505.  
  506. <p id="info_msg" name="SignatureTitle">Подпись:</p>
  507. <div id="item_border">
  508. <textarea id="SignatureTxtBox" style="font-size:9pt;height:600px;width:100%;resize:none;border:0;"></textarea>
  509. <script language="javascript">
  510. var txtDataToSign = "Hello World";
  511. document.getElementById("SignatureTxtBox").innerHTML = "";
  512. var canPromise = !!window.Promise;
  513. if(canPromise) {
  514. cadesplugin.then(function () {
  515. Common_CheckForPlugIn();
  516. },
  517. function(error) {
  518. document.getElementById('PluginEnabledImg').setAttribute("src", "Img/red_dot.png");
  519. document.getElementById('PlugInEnabledTxt').innerHTML = error;
  520. }
  521. );
  522. } else {
  523. window.addEventListener("message", function (event){
  524. if (event.data == "cadesplugin_loaded") {
  525. CheckForPlugIn_NPAPI();
  526. } else if(event.data == "cadesplugin_load_error") {
  527. document.getElementById('PluginEnabledImg').setAttribute("src", "Img/red_dot.png");
  528. document.getElementById('PlugInEnabledTxt').innerHTML = "Плагин не загружен";
  529. }
  530. },
  531. false);
  532. window.postMessage("cadesplugin_echo_request", "*");
  533. }
  534. </script>
  535. </div>
  536. <p></p>
  537. <p id="info_msg" name="TimeTitle">Время выполнения: </p>
  538. </div>-->
  539. <!--11111-->
  540. <!---->
  541. <?
  542. global $APPLICATION;
  543. $r = $APPLICATION->EndBufferContentMan();
  544.  
  545. \Bitrix\Main\Context::getCurrent()->getResponse()->flush($r);
  546. //require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
  547. //require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
Add Comment
Please, Sign In to add comment