{"id":529,"date":"2023-08-31T05:32:48","date_gmt":"2023-08-31T05:32:48","guid":{"rendered":"https:\/\/michanorg.sites.sch.gr\/wordpress\/?p=529"},"modified":"2023-08-31T06:37:37","modified_gmt":"2023-08-31T06:37:37","slug":"%cf%80%ce%b1%cf%81a%ce%b4%ce%b5%ce%af%ce%b3%ce%bc%ce%b1%cf%84%ce%b1-%ce%ba%ce%bb%ce%ae%cf%83%ce%b5%cf%89%ce%bd-%cf%83%cf%84%ce%bf-%ce%ba%cf%83%ce%b7%ce%b4%ce%b5-%ce%bc%ce%b5-php","status":"publish","type":"post","link":"https:\/\/michanorg.sites.sch.gr\/wordpress\/?p=529","title":{"rendered":"\u03a0\u03b1\u03c1a\u03b4\u03b5\u03af\u03b3\u03bc\u03b1\u03c4\u03b1 \u03ba\u03bb\u03ae\u03c3\u03b5\u03c9\u03bd \u03c3\u03c4\u03bf \u039a\u03a3\u0397\u0394\u0395 \u03bc\u03b5 php"},"content":{"rendered":"<div class=\"entry\">\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u03a0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3\u03bc\u03b1 1.<\/strong> \u039b\u03ae\u03c8\u03b7 authorization token, \u03c7\u03c1\u03b7\u03c3\u03b9\u03bc\u03bf\u03c0\u03bf\u03b9\u03ce\u03bd\u03c4\u03b1\u03c2 php.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$url = \"https:\/\/sddd.mindigital-shde.gr\/api\/v1\/authenticate\";\ntry{\n\/\/ \u03c4\u03bc\u03ae\u03bc\u03b1 1\u03bf -----------\u039c\u03c0\u03bf\u03c1\u03b5\u03af \u03bd\u03b1 \u03c0\u03b1\u03c1\u03b1\u03bb\u03b7\u03c6\u03b8\u03b5\u03af \u03b1\u03c6\u03bf\u03c1\u03ac \u03c4\u03bf\u03bd \u03ba\u03c9\u03b4\u03b9\u03ba\u03cc \u03c5\u03c0\u03b7\u03c1\u03b5\u03c3\u03af\u03b1\u03c2 ---\t\t\n                $myfile = fopen($ksideSecrFile , \"r\"); \/\/ \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03bc\u03b5 \u03c4\u03bf\u03bd \u03ba\u03c9\u03b4\u03b9\u03ba\u03cc \u03c4\u03b7\u03c2 \u03c5\u03c0\u03b7\u03c1\u03b5\u03c3\u03af\u03b1\u03c2 \u03ba\u03c1\u03c5\u03c0\u03c4\u03bf\u03b3\u03c1\u03b1\u03c6\u03b7\u03bc\u03ad\u03bd\u03bf\n\t\t$sec = fgets($myfile);\n\t\tfclose($myfile);\n\t\t$sec_dec = openssl_decrypt($sec, '***********', \"****************\", 0, \"****************\");  \n\t\t\/\/\u03b1\u03c0\u03bf\u03ba\u03c1\u03c5\u03c0\u03c4\u03bf\u03b3\u03c1\u03ac\u03c6\u03b7\u03c3\u03b7 \u03c4\u03bf\u03c5 \u03ba\u03c9\u03b4\u03b9\u03ba\u03bf\u03cd\n\/\/!-- \u03c4\u03bc\u03ae\u03bc\u03b1 1\u03bf\n\t\t<strong>$postdata = array(\n\t\t\t'SectorCode' =&gt; $_SESSION&#91;'sectorCode'],\n\t\t\t'ClientId' =&gt; $_SESSION&#91;'clientId'],\n\t\t\t'ClientSecret' =&gt; $sec_dec\n\t\t);\n\t\t$fields_string = http_build_query($postdata);\n\t\t$ch = curl_init($url); \n\t\tcurl_setopt($ch, CURLOPT_POST, 1);\n\t\tcurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n\t\tcurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);\n\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string );\n\t\t$data = curl_exec($ch);<\/strong>\n\t\tif($data === false){\n\t\t\t$error = curl_error($ch);\n\t\t\techo $error;\n\t\t\tdie('\u0391\u03b4\u03c5\u03bd\u03b1\u03bc\u03af\u03b1 \u03c3\u03cd\u03bd\u03b4\u03b5\u03c3\u03b7\u03c2 \u03c3\u03c4\u03bf \u039a\u03a3\u0397\u0394\u0395');\n\t\t}else{\n\/\/ \u03c4\u03bc\u03ae\u03bc\u03b1 2\u03bf ------------\u039c\u03c0\u03bf\u03c1\u03b5\u03af \u03bd\u03b1 \u03c0\u03b1\u03c1\u03b1\u03bb\u03b7\u03c6\u03b8\u03b5\u03af \u03b1\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c4\u03bf\u03c5 token ---\n\t\t\t$myfile = fopen($ksideTokenFile, \"w\") or die(\"Unable to open file!\");\n\t\t\t$data_enc = openssl_encrypt($data, '*********', \"****************\", 0, \"\n****************\");\n\t\t\tfwrite($myfile,$data_enc);\n\t\t\tfclose($myfile);\n\/\/!-- \u03c4\u03bc\u03ae\u03bc\u03b1 2\u03bf\n\t\t}\n\t\tcurl_close($ch);\n\t}catch(Exception  $e){\n\t\techo '\u03a3\u03c6\u03ac\u03bb\u03bc\u03b1: '.$e-&gt;getMessage();\n\t\tdie(\"\u03a3\u03c6\u03ac\u03bb\u03bc\u03b1 \u03a3\u03cd\u03bd\u03b4\u03b5\u03c3\u03b7\u03c2\");\n\t}<\/code><\/pre>\n\n\n\n<p><strong>\u03a0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3\u03bc\u03b1 2.<\/strong> \u0391\u03c0\u03bf\u03c3\u03c4\u03bf\u03bb\u03ae \u03b2\u03b1\u03c3\u03b9\u03ba\u03bf\u03cd \u03b5\u03b3\u03b3\u03c1\u03ac\u03c6\u03bf\u03c5 \u03bc\u03b5 \u03c4\u03b1 \u03b5\u03bb\u03ac\u03c7\u03b9\u03c3\u03c4\u03b1 \u03b4\u03c5\u03bd\u03b1\u03c4\u03ac \u03bc\u03b5\u03c4\u03b1\u03b4\u03b5\u03b4\u03bf\u03bc\u03ad\u03bd\u03b1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>try{\n\t\t\t\/\/\u0391\u03bd\u03ad\u03b2\u03b1\u03c3\u03bc\u03b1 \u0392\u03b1\u03c3\u03b9\u03ba\u03bf\u03cd \u0391\u03c1\u03c7\u03b5\u03af\u03bf\u03c5\n\t\t\t$basicFile = $_FILES&#91;\"selectedFile\".$tobeSigned];\n\t\t\t$target_file = $target_dir.\"\/\".basename($_FILES&#91;\"selectedFile\".$tobeSigned]&#91;\"name\"]);\n\t\t\tmove_uploaded_file($_FILES&#91;\"selectedFile\".$tobeSigned]&#91;\"tmp_name\"],$target_file);\n\n\t\t\t<strong>$metadata = array(\n\t\t\t'Subject' =&gt; $_POST&#91;'Subject'],\n\t\t\t'RecipientSectorCodes'=&gt;explode(\",\",(int)$_POST&#91;'RecipientSectorCodes']),\n\t\t\t'OrgChartVersion'=&gt;(int)$_POST&#91;'OrgChartVersion'],\n\t\t\t'LocalSectorProtocolNo'=&gt;(int)$_POST&#91;'LocalSectorProtocolNo'],\n\t\t\t'LocalSectorProtocolDate'=&gt;$_POST&#91;'LocalSectorProtocolDate'].\"T01:00:00.000Z\",\n\t\t\t'LocalSectorProtocolNo'=&gt;(int)$_POST&#91;'LocalSectorProtocolNo'],\n\t\t\t\/\/'LocalSectorProtocolDate'=&gt;'2021-01-21T13:43:19.334Z',\n\t\t\t'IsFinal'=&gt;(int)$isFinal\n\t\t\t);<\/strong>\n\t\t\t\t\n\t\t\t<strong>$metadata = json_encode($metadata);\n\n\t\t\t$authorization =\"Authorization: Bearer \".$accessToken;\n\t\t\t$pathToFile = $_SESSION&#91;'websiteFolder'].'\/nocc-1.9.8\/kside\/api_calls\/'.$target_file;\n\t\t\t$postFields= array('DocumentMetadata'=&gt;$metadata,'DocumentContent' =&gt; new CURLFile($pathToFile));\n\n\t\t\t$ch = curl_init($url); \n\t\t\tcurl_setopt($ch, CURLOPT_POST, 1);\n\t\t\tcurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n\t\t\tcurl_setopt($ch, CURLOPT_MAXREDIRS, 10);\n\t\t\tcurl_setopt($ch, CURLOPT_TIMEOUT, 0);\n\t\t\tcurl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);\n\t\t\tcurl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);\n\t\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS,$postFields);\n\t\t\tcurl_setopt($ch, CURLOPT_ENCODING , \"\");\n\t\t\tcurl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart\/form-data ',$authorization));\n\t\t\t$data = curl_exec($ch);<\/strong>\n\t\t\n\t\t\t\/\/convert the XML result into array\n\t\t\tif($data === false){\n\t\t\t\t$error = curl_error($ch);\n\t\t\t\techo $error;\n\t\t\t\tdie(' error occured');\n\t\t\t}else{\n\t\t\t\t\/\/var_dump(curl_getinfo($ch));\n\t\t\t\t$result = json_decode($data,true);\n\t\t\t\t\/\/echo $data;\n\t\t\t\tif (isset($result&#91;'SideTrackingId'])){\n\t\t\t\t\t$isError = $data;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$protocol = $result&#91;\"DocumentProtocolNo\"];\n\t\t\t\t} ...<\/code><\/pre>\n\n\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u03a0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3\u03bc\u03b1 1. \u039b\u03ae\u03c8\u03b7 authorization token, \u03c7\u03c1\u03b7\u03c3\u03b9\u03bc\u03bf\u03c0\u03bf\u03b9\u03ce\u03bd\u03c4\u03b1\u03c2 php. \u03a0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3\u03bc\u03b1 2. \u0391\u03c0\u03bf\u03c3\u03c4\u03bf\u03bb\u03ae \u03b2\u03b1\u03c3\u03b9\u03ba\u03bf\u03cd \u03b5\u03b3\u03b3\u03c1\u03ac\u03c6\u03bf\u03c5 \u03bc\u03b5 \u03c4\u03b1 \u03b5\u03bb\u03ac\u03c7\u03b9\u03c3\u03c4\u03b1 \u03b4\u03c5\u03bd\u03b1\u03c4\u03ac \u03bc\u03b5\u03c4\u03b1\u03b4\u03b5\u03b4\u03bf\u03bc\u03ad\u03bd\u03b1<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[4,10,9],"_links":{"self":[{"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/529"}],"collection":[{"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=529"}],"version-history":[{"count":2,"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/529\/revisions"}],"predecessor-version":[{"id":531,"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/529\/revisions\/531"}],"wp:attachment":[{"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michanorg.sites.sch.gr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}