PluginProbe
HTTP Headers / 1.10.5
HTTP Headers v1.10.5
1.19.5 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.14.0 1.14.1 1.14.2 1.15.0 All 60 releases
http-headers / views / ajax-inspect.php

ajax-inspect.php in HTTP Headers 1.10.5, at views/ajax-inspect.php

132 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!(isset($_POST['url']) && preg_match('|^https?://|', $_POST['url'])))
3 {
4 ?>
5 <section class="hh-panel">
6 <h3><span class="hh-highlight"><?php _e('URL malformed', 'http-headers'); ?></span></h3>
7 </section>
8 <?php
9 exit;
10 }
11
12 include 'includes/http.class.php';
13 include 'includes/config.inc.php';
14 $http = new Http();
15
16 if (isset($_POST['authentication'], $_POST['auth_type'], $_POST['username'], $_POST['password'])
17 && in_array($_POST['auth_type'], array('basic', 'digest', 'gss', 'ntlm'))
18 && !empty($_POST['username'])
19 && !empty($_POST['password'])
20 )
21 {
22 $http->setAuthType($_POST['auth_type']);
23 $http->setPassword($_POST['password']);
24 $http->setUsername($_POST['username']);
25 }
26
27 $http->request($_POST['url']);
28 $responseHeaders = $http->getResponseHeaders();
29 $status = $http->getHttpCode();
30 $error = $http->getError();
31 if ($status !== 200)
32 {
33 ?>
34 <section class="hh-panel">
35 <h3><span class="hh-highlight"><?php _e('HTTP Status', 'http-headers'); ?>: <?php echo $status; ?></span></h3>
36 <p><?php
37 switch ($status)
38 {
39 case 400:
40 echo 'Bad Request';
41 break;
42 case 401:
43 echo 'Unauthorized';
44 break;
45 case 403:
46 echo 'Forbidden';
47 break;
48 case 404:
49 echo 'Not Found';
50 break;
51 case 405:
52 echo 'Method Not Allowed';
53 break;
54 default:
55 }
56 ?></p>
57 </section>
58 <?php
59 exit;
60 }
61 ?>
62 <section class="hh-panel">
63 <h3><span class="hh-highlight"><?php _e('Response headers', 'http-headers'); ?></span></h3>
64 <table class="hh-results">
65 <thead>
66 <tr>
67 <th style="width: 30%"><?php _e('Header', 'http-headers'); ?></th>
68 <th><?php _e('Value', 'http-headers'); ?></th>
69 </tr>
70 </thead>
71 <tbody>
72 <?php
73 $reportOnly = array('content-security-policy-report-only', 'public-key-pins-report-only');
74 foreach ($responseHeaders as $k => $v)
75 {
76 $k = strtolower($k);
77 $found = in_array($k, $reportOnly);
78 ?>
79 <tr<?php echo array_key_exists($k, $headers) || $found ? ' class="hh-found"' : NULL; ?>>
80 <td><?php echo htmlspecialchars($k); ?></td>
81 <td><?php echo htmlspecialchars($v); ?></td>
82 </tr>
83 <?php
84 }
85 ?>
86 </tbody>
87 </table>
88 </section>
89 <?php
90 $special = array('content-security-policy', 'public-key-pins');
91 $exclude = array('custom-headers', 'cookie-security', 'x-powered-by');
92 $missing = array();
93 foreach ($headers as $k => $v)
94 {
95 if (!array_key_exists($k, $responseHeaders)
96 && !in_array($k, $exclude)
97 && !(in_array($k, $special) && array_key_exists($k . '-report-only', $responseHeaders) ))
98 {
99 $missing[$k] = @$categories[$v[2]];
100 }
101 }
102
103 if (!empty($missing))
104 {
105 asort($missing);
106 ?>
107 <section class="hh-panel">
108 <h3><span class="hh-highlight"><?php _e('Missing headers', 'http-headers'); ?></span></h3>
109 <table class="hh-results">
110 <thead>
111 <tr>
112 <th style="width: 30%"><?php _e('Header', 'http-headers'); ?></th>
113 <th><?php _e('Category', 'http-headers'); ?></th>
114 </tr>
115 </thead>
116 <tbody>
117 <?php
118 foreach ($missing as $k => $v)
119 {
120 ?>
121 <tr>
122 <td><a href="<?php echo get_admin_url(); ?>options-general.php?page=http-headers&amp;header=<?php echo htmlspecialchars($k); ?>"><?php echo $k; ?></a></td>
123 <td><?php echo $v; ?></td>
124 </tr>
125 <?php
126 }
127 ?>
128 </tbody>
129 </table>
130 </section>
131 <?php
132 }