$code ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); return @file_get_contents('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; } //-------------------------------------------------------------------------------- // XML output... //-------------------------------------------------------------------------------- if ($isXmlOutput) { //if XML output... header('Content-Type: text/xml'); if (!$isCodePosted) { //if NO code posted... echo "\n\n"; exit; } $output = get_democlient_output(cut_string($_POST['code'])); if ($output === false) { //if NO demo client output... echo "\n\n"; exit; } echo $output; exit; } //-------------------------------------------------------------------------------- ?> Online Demo Report - Cppcheck

Online Demo Report

errors->error as $error) { //for all errors... $severity = (string)$error->attributes()->severity; $msg = (string)$error->attributes()->msg; $line = (string)$error->location->attributes()->line; if (!empty($severity) && !empty($msg) && !empty($line)) { //if complete error... $parsed[] = array('severity' => $severity, 'msg' => $msg, 'line' => $line); } } return $parsed; } catch (Exception $ex) { return array(); } } if ($isCodePosted) { //if code posted... include_once '../../site/geshi/geshi.php'; $code = cut_string($_POST['code']); $geshi = new GeSHi($code, 'cpp'); $geshi->enable_classes(); $geshi->set_header_type(GESHI_HEADER_PRE_TABLE); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_overall_class('geshicode'); echo "

Input

\n"; echo $geshi->parse_code(); echo "

Output

\n"; $output = get_democlient_output($code); if (!$output === false) { $results = parse_democlient_output($output); if (!empty($results)) { echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo "\n"; foreach ($results as $result) { //for each result... echo " \n"; } echo "\n"; echo "
LineSeverityMessage
" . htmlspecialchars($result['line']) . "" . htmlspecialchars($result['severity']) . "" . htmlspecialchars($result['msg']) . "
\n"; } else { echo "

No errors found.

\n"; } } else { echo "

Problem with demo client. Please try again.

\n"; } } else { //if NO code posted... echo "

Use the online demo page to create the report.

\n"; } ?>