snipt

Ctrl+h for KB shortcuts

PHP

download an XML format description from PRONOM registry

<form action="http://www.nationalarchives.gov.uk/PRONOM/Format/proFormatDetailListAction.aspx" id="frmSaveAs" name="SaveAs" method="post">
    <input type="hidden" id="hidSaveFormAction" name="strAction" value="Save As XML" />
    <input type='visible' name='strFileFormatID' value='788' />
</form>

<a href="#" class="plainblackb" onclick="document.getElementById('frmSaveAs').strAction.value = 'Save As XML'; document.getElementById('frmSaveAs').submit();">XML</a> 

<?
$headers = apache_request_headers();

foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
} 
echo "------------------------<br/>";

$domain = "localhost";
$portno = 80;
$method = "HEAD";
$url    = "/";

$http_response = "";
$http_request .= $method." ".$url ." HTTP/1.0\r\n";
$http_request .= "\r\n";

$fp = fsockopen($domain, $portno, $errno, $errstr);
if($fp){
    fputs($fp, $http_request);
    while (!feof($fp)) $http_response .= fgets($fp, 128);
    fclose($fp);
}

echo "http:".$http_response; 
?>
https://snipt.net/embed/a0dac09d3c5d0c2557ab484351f45398/
/raw/a0dac09d3c5d0c2557ab484351f45398/
a0dac09d3c5d0c2557ab484351f45398
php
PHP
33
2019-07-20T12:18:46
True
False
False
/api/public/snipt/8699/
download-an-xml-format-description-from-pronom-registry
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a> <a href="#L-13">13</a> <a href="#L-14">14</a> <a href="#L-15">15</a> <a href="#L-16">16</a> <a href="#L-17">17</a> <a href="#L-18">18</a> <a href="#L-19">19</a> <a href="#L-20">20</a> <a href="#L-21">21</a> <a href="#L-22">22</a> <a href="#L-23">23</a> <a href="#L-24">24</a> <a href="#L-25">25</a> <a href="#L-26">26</a> <a href="#L-27">27</a> <a href="#L-28">28</a> <a href="#L-29">29</a> <a href="#L-30">30</a> <a href="#L-31">31</a> <a href="#L-32">32</a> <a href="#L-33">33</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">&lt;form action=&quot;http://www.nationalarchives.gov.uk/PRONOM/Format/proFormatDetailListAction.aspx&quot; id=&quot;frmSaveAs&quot; name=&quot;SaveAs&quot; method=&quot;post&quot;&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> &lt;input type=&quot;hidden&quot; id=&quot;hidSaveFormAction&quot; name=&quot;strAction&quot; value=&quot;Save As XML&quot; /&gt;</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> &lt;input type=&#39;visible&#39; name=&#39;strFileFormatID&#39; value=&#39;788&#39; /&gt;</span> </span><span id="L-4"><a name="L-4"></a><span class="x">&lt;/form&gt;</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="x">&lt;a href=&quot;#&quot; class=&quot;plainblackb&quot; onclick=&quot;document.getElementById(&#39;frmSaveAs&#39;).strAction.value = &#39;Save As XML&#39;; document.getElementById(&#39;frmSaveAs&#39;).submit();&quot;&gt;XML&lt;/a&gt; </span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="cp">&lt;?</span> </span><span id="L-9"><a name="L-9"></a><span class="nv">$headers</span> <span class="o">=</span> <span class="nb">apache_request_headers</span><span class="p">();</span> </span><span id="L-10"><a name="L-10"></a> </span><span id="L-11"><a name="L-11"></a><span class="k">foreach</span> <span class="p">(</span><span class="nv">$headers</span> <span class="k">as</span> <span class="nv">$header</span> <span class="o">=&gt;</span> <span class="nv">$value</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-12"><a name="L-12"></a><span class="k">echo</span> <span class="s2">&quot;</span><span class="si">$header</span><span class="s2">: </span><span class="si">$value</span><span class="s2"> &lt;br /&gt;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-13"><a name="L-13"></a><span class="p">}</span> </span><span id="L-14"><a name="L-14"></a><span class="k">echo</span> <span class="s2">&quot;------------------------&lt;br/&gt;&quot;</span><span class="p">;</span> </span><span id="L-15"><a name="L-15"></a> </span><span id="L-16"><a name="L-16"></a><span class="nv">$domain</span> <span class="o">=</span> <span class="s2">&quot;localhost&quot;</span><span class="p">;</span> </span><span id="L-17"><a name="L-17"></a><span class="nv">$portno</span> <span class="o">=</span> <span class="mi">80</span><span class="p">;</span> </span><span id="L-18"><a name="L-18"></a><span class="nv">$method</span> <span class="o">=</span> <span class="s2">&quot;HEAD&quot;</span><span class="p">;</span> </span><span id="L-19"><a name="L-19"></a><span class="nv">$url</span> <span class="o">=</span> <span class="s2">&quot;/&quot;</span><span class="p">;</span> </span><span id="L-20"><a name="L-20"></a> </span><span id="L-21"><a name="L-21"></a><span class="nv">$http_response</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">;</span> </span><span id="L-22"><a name="L-22"></a><span class="nv">$http_request</span> <span class="o">.=</span> <span class="nv">$method</span><span class="o">.</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="nv">$url</span> <span class="o">.</span><span class="s2">&quot; HTTP/1.0</span><span class="se">\r\n</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-23"><a name="L-23"></a><span class="nv">$http_request</span> <span class="o">.=</span> <span class="s2">&quot;</span><span class="se">\r\n</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-24"><a name="L-24"></a> </span><span id="L-25"><a name="L-25"></a><span class="nv">$fp</span> <span class="o">=</span> <span class="nb">fsockopen</span><span class="p">(</span><span class="nv">$domain</span><span class="p">,</span> <span class="nv">$portno</span><span class="p">,</span> <span class="nv">$errno</span><span class="p">,</span> <span class="nv">$errstr</span><span class="p">);</span> </span><span id="L-26"><a name="L-26"></a><span class="k">if</span><span class="p">(</span><span class="nv">$fp</span><span class="p">){</span> </span><span id="L-27"><a name="L-27"></a> <span class="nb">fputs</span><span class="p">(</span><span class="nv">$fp</span><span class="p">,</span> <span class="nv">$http_request</span><span class="p">);</span> </span><span id="L-28"><a name="L-28"></a> <span class="k">while</span> <span class="p">(</span><span class="o">!</span><span class="nb">feof</span><span class="p">(</span><span class="nv">$fp</span><span class="p">))</span> <span class="nv">$http_response</span> <span class="o">.=</span> <span class="nb">fgets</span><span class="p">(</span><span class="nv">$fp</span><span class="p">,</span> <span class="mi">128</span><span class="p">);</span> </span><span id="L-29"><a name="L-29"></a> <span class="nb">fclose</span><span class="p">(</span><span class="nv">$fp</span><span class="p">);</span> </span><span id="L-30"><a name="L-30"></a><span class="p">}</span> </span><span id="L-31"><a name="L-31"></a> </span><span id="L-32"><a name="L-32"></a><span class="k">echo</span> <span class="s2">&quot;http:&quot;</span><span class="o">.</span><span class="nv">$http_response</span><span class="p">;</span> </span><span id="L-33"><a name="L-33"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
description, format, php, pronom