Web: Use nicer "Online Demo Report" output
This commit is contained in:
parent
e3c8dacb1c
commit
75f07ff10a
|
@ -2,16 +2,10 @@
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<title>Developer Information - Cppcheck</title>
|
<title>Online Demo - Cppcheck</title>
|
||||||
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Orbitron&text=Cppcheck" />
|
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Orbitron&text=Cppcheck" />
|
||||||
<link rel="stylesheet" type="text/css" href="/site/css/all.css" />
|
<link rel="stylesheet" type="text/css" href="/site/css/all.css" />
|
||||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||||
<link rel="alternate" type="application/atom+xml" title="Recent Commits to cppcheck:master"
|
|
||||||
href="https://github.com/danmar/cppcheck/commits/master.atom" />
|
|
||||||
<link rel="alternate" type="application/atom+xml" title="Trac Timeline"
|
|
||||||
href="http://sourceforge.net/apps/trac/cppcheck/timeline?changeset=on&ticket=on&milestone=on&wiki=on&max=50&daysback=90&format=rss" />
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
|
|
||||||
<script src="/site/js/github.js" type="text/javascript"></script>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function checkCodeLength() {
|
function checkCodeLength() {
|
||||||
if (document.f.code.value.length > 1024) {
|
if (document.f.code.value.length > 1024) {
|
||||||
|
@ -45,7 +39,7 @@
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h2>Online Demo</h2>
|
<h2>Online Demo</h2>
|
||||||
<form action="http://cppcheck.sourceforge.net/cgi-bin/democlient.cgi" name="f" onsubmit="return checkCodeLength();" method="post" target="_blank">
|
<form action="/demo/report/" name="f" onsubmit="return checkCodeLength();" method="post" target="_blank">
|
||||||
<p><label for="code">Enter code:</label><br />
|
<p><label for="code">Enter code:</label><br />
|
||||||
<textarea id="code" name="code" rows="20" cols="80">
|
<textarea id="code" name="code" rows="20" cols="80">
|
||||||
void f()
|
void f()
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<title>Online Demo Report - Cppcheck</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Orbitron&text=Cppcheck" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="/site/css/all.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="header">
|
||||||
|
<div class="wrap">
|
||||||
|
<h1>Cppcheck</h1>
|
||||||
|
<p>A tool for static C/C++ code analysis</p>
|
||||||
|
</div> <!-- .wrap -->
|
||||||
|
</div> <!-- #header -->
|
||||||
|
<div id="tabs">
|
||||||
|
<div class="wrap">
|
||||||
|
<ul>
|
||||||
|
<li><a href="/">Home</a></li>
|
||||||
|
<li><a href="http://sourceforge.net/apps/mediawiki/cppcheck/">Wiki</a></li>
|
||||||
|
<li><a href="http://sourceforge.net/apps/phpbb/cppcheck/">Forum</a></li>
|
||||||
|
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Trac</a></li>
|
||||||
|
<li><a href="/devinfo/" title="Developer Information">Developer Info</a></li>
|
||||||
|
<li><em><a href="/demo/">Online Demo</a></em></li>
|
||||||
|
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
|
||||||
|
</ul>
|
||||||
|
</div> <!-- .wrap -->
|
||||||
|
</div> <!-- #tabs -->
|
||||||
|
<div id="content">
|
||||||
|
<div class="wrap">
|
||||||
|
<h2>Online Demo Report</h2>
|
||||||
|
<?php
|
||||||
|
$isCodePosted = isset($_POST['code']) && !empty($_POST['code']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ...
|
||||||
|
* @param string $code Source code
|
||||||
|
* @return string Output lines
|
||||||
|
*/
|
||||||
|
function get_democlient_outout($code) {
|
||||||
|
$postdata = http_build_query(
|
||||||
|
array(
|
||||||
|
'code' => $code
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$opts = array('http' =>
|
||||||
|
array(
|
||||||
|
'method' => 'POST',
|
||||||
|
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||||
|
'content' => $postdata
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$context = stream_context_create($opts);
|
||||||
|
|
||||||
|
return file('http://cppcheck.sourceforge.net/cgi-bin/democlient.cgi', false, $context);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cut_string($string, $length = 1024) {
|
||||||
|
if (strlen($string) > $length) {
|
||||||
|
return substr($string, 0, $length);
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isCodePosted) { //if code posted...
|
||||||
|
echo "<h3>Input</h3>\n";
|
||||||
|
echo "<pre class=\"code\">" . htmlspecialchars($_POST['code']) . "</pre>\n";
|
||||||
|
|
||||||
|
echo "<h3>Output</h3>\n";
|
||||||
|
|
||||||
|
$code = cut_string($_POST['code']);
|
||||||
|
$lines = get_democlient_outout($code);
|
||||||
|
foreach ($lines as $line) { //for each output line...
|
||||||
|
$line = trim($line);
|
||||||
|
if (empty($line)) { //if empty line...
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
echo "<p>" . htmlspecialchars($line) . "</p>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "<p>Use the <a href=\"/demo/\">online demo</a> page to create the report.</p>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div> <!-- .wrap -->
|
||||||
|
</div> <!-- #content -->
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue