| 1 |
<?php |
| 2 |
// Put here the path to KWStyle |
| 3 |
//$kwstyle = "/www/CADDLab/kwstyle/KWStyle"; |
| 4 |
$kwstyle = "/projects/KWStyle/KWStyle-Linux/KWStyle"; |
| 5 |
|
| 6 |
//$kwstyle2 = "/www/CADDLab/kwstyle/"; |
| 7 |
$kwstyle2 = "/projects/KWStyle/KWStyle/Web/"; |
| 8 |
|
| 9 |
Header_POST["Header"]; |
| 10 |
$xmlfile = $_POST["xmlfile"]; |
| 11 |
$xmlfileselect = $_GET["xmlfileselect"]; |
| 12 |
|
| 13 |
if($_FILES['userfile']['name']) |
| 14 |
{ |
| 15 |
$newloc = "/tmp/".$_FILES['userfile']['name']; |
| 16 |
move_uploaded_file($_FILES['userfile']['tmp_name'],$newloc); |
| 17 |
$command = $kwstyle." -xml "; |
| 18 |
$command .= $xmlfile; |
| 19 |
$command .= " -exporthtml "; |
| 20 |
$command .= $newloc; |
| 21 |
//echo $command; |
| 22 |
$output = shell_exec($command); |
| 23 |
echo $output; |
| 24 |
} // end submit |
| 25 |
|
| 26 |
?> |
| 27 |
|
| 28 |
<script language="Javascript"> |
| 29 |
function test(value) |
| 30 |
{ |
| 31 |
url = "index.php?xmlfileselect="+value; |
| 32 |
window.location.href = url; |
| 33 |
} |
| 34 |
</script> |
| 35 |
|
| 36 |
<?php |
| 37 |
$currentfile = ""; |
| 38 |
?> |
| 39 |
|
| 40 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 41 |
<html> |
| 42 |
<head> |
| 43 |
<title>KWStyle - The Source Code Checker</title> |
| 44 |
<meta name="keywords" content="Style, Checker, Source, Code, Kitware, Julien, Jomier" /> |
| 45 |
<meta name="description" content="The Source Code Checker" /> |
| 46 |
<meta name="rating" content="General" /> |
| 47 |
<meta name="robots" content="ALL" /> |
| 48 |
<link rel="stylesheet" href="default.css" type="text/css" /> |
| 49 |
<link rel="icon" href="/KWStyle/favicon.ico" type="image/ico" /> |
| 50 |
<link rel="shortcut icon" href="/KWStyle/favicon.ico" /> |
| 51 |
<style type="text/css"> |
| 52 |
<!-- |
| 53 |
.style7 {font-size: 12px} |
| 54 |
--> |
| 55 |
</style> |
| 56 |
</head> |
| 57 |
|
| 58 |
<body topmargin="0" leftmargin="0" alink="#000000" bgcolor="#ffffff" link="#0000ff" marginheight="0" marginwidth="0" text="black" vlink="#000000"> |
| 59 |
<img src="images/TitleBar.jpg" width="650" height="170"> |
| 60 |
<table width="100%" border="0"> |
| 61 |
<tr> |
| 62 |
<td width="13%" valign="top"> |
| 63 |
<table style="background-image: |
| 64 |
url('images/CurvedSideBar.jpg'); background-repeat:no-repeat; |
| 65 |
border: 0 ridge #800000" border="0" cellpadding="4" cellspacing="0" width="143"> |
| 66 |
<tbody> |
| 67 |
<tr> |
| 68 |
<td width="135" height="369" valign="top"> <br /> |
| 69 |
<br /> |
| 70 |
<br /> |
| 71 |
<br /> |
| 72 |
<br /> |
| 73 |
<a class="left" href="https://public.kitware.com/KWStyle/index.htm"><b> Home</b></a><br /> |
| 74 |
<br /> |
| 75 |
<a class="left" href="https://public.kitware.com/KWStyle/features.htm"><b> Features</b></a><br /> |
| 76 |
<br /> |
| 77 |
<a class="left" href="http://192.168.113.30/KWStyle"><b> Check my file</b></a><br /> |
| 78 |
<br /> |
| 79 |
<a class="left" href="https://public.kitware.com/KWStyle/download.htm"><b> Download</b></a><br /> |
| 80 |
<br /> |
| 81 |
<a class="left" href="https://public.kitware.com/KWStyle/example.htm"><b> Example</b></a><br /> |
| 82 |
<br /> |
| 83 |
<a class="left" href="https://public.kitware.com/KWStyle/testing.htm"><b> Testing</b></a><br /> |
| 84 |
<br /> |
| 85 |
<a class="left" href="https://public.kitware.com/KWStyle/sponsors.htm"><b> Sponsors</b></a><br /> |
| 86 |
<br /> |
| 87 |
<a class="left" href="https://public.kitware.com/KWStyle/documentation.htm"><b> Documentation</b></a><br /> |
| 88 |
<br /> |
| 89 |
<a class="left" href="https://public.kitware.com/KWStyle/copyright.htm"><b> Copyright</b></a><br /> |
| 90 |
<br /> |
| 91 |
<a class="left" href="http://public.kitware.com/Bug/"><b> Bug |
| 92 |
Tracker</b></a><br /> |
| 93 |
<br /> |
| 94 |
</td> |
| 95 |
</tr> |
| 96 |
</tbody> |
| 97 |
</table> |
| 98 |
</td> |
| 99 |
<td width="87%" valign="top"> |
| 100 |
<!-- The data encoding type, enctype, MUST be specified as below --> |
| 101 |
<form enctype="multipart/form-data" action=<?php echo $_SERVER['PHP_SELF'];?> method="POST"> |
| 102 |
<!-- MAX_FILE_SIZE must precede the file input field --> |
| 103 |
<p> |
| 104 |
Select a predefined style: |
| 105 |
<select ONCHANGE="test(this.options[this.selectedIndex].value)" name="xmlfile" id="xmlfile"> |
| 106 |
<?php |
| 107 |
// create a handler for the directory |
| 108 |
|
| 109 |
$handler = opendir($kwstyle2); |
| 110 |
|
| 111 |
$i = 0; |
| 112 |
|
| 113 |
// keep going until all files in directory have been read |
| 114 |
while ($file = readdir($handler)) |
| 115 |
{ |
| 116 |
// if $file isn't this directory or its parent, |
| 117 |
// add it to the results array |
| 118 |
if (strstr($file,"kws.xml")) |
| 119 |
{ |
| 120 |
if($i==0) |
| 121 |
{ |
| 122 |
$currentfile = $file; |
| 123 |
} |
| 124 |
$name = substr($file,0,strlen($file)-8); |
| 125 |
echo "<option value=".$file; |
| 126 |
if(strstr($file,$xmlfileselect)) // select the last revision |
| 127 |
{ |
| 128 |
$currentfile = $file; |
| 129 |
echo(" selected"); |
| 130 |
} |
| 131 |
echo ">"; |
| 132 |
echo $name; |
| 133 |
echo "</option>"; |
| 134 |
$i++; |
| 135 |
} |
| 136 |
|
| 137 |
} |
| 138 |
closedir($handler); |
| 139 |
?> |
| 140 |
</select> |
| 141 |
<br /> |
| 142 |
<br /> |
| 143 |
<?php |
| 144 |
|
| 145 |
class xmlParser{ |
| 146 |
var $xml_obj = null; |
| 147 |
var $output = array(); |
| 148 |
var $attrs; |
| 149 |
|
| 150 |
function xmlParser(){ |
| 151 |
$this->xml_obj = xml_parser_create(); |
| 152 |
xml_set_object($this->xml_obj,$this); |
| 153 |
xml_set_character_data_handler($this->xml_obj, 'dataHandler'); |
| 154 |
xml_set_element_handler($this->xml_obj, "startHandler", "endHandler"); |
| 155 |
} |
| 156 |
|
| 157 |
function parse($path){ |
| 158 |
if (!($fp = fopen($path, "r"))) { |
| 159 |
die("Cannot open XML data file: $path"); |
| 160 |
return false; |
| 161 |
} |
| 162 |
|
| 163 |
while ($data = fread($fp, 4096)) { |
| 164 |
if (!xml_parse($this->xml_obj, $data, feof($fp))) { |
| 165 |
die(sprintf("XML error: %s at line %d", |
| 166 |
xml_error_string(xml_get_error_code($this->xml_obj)), |
| 167 |
xml_get_current_line_number($this->xml_obj))); |
| 168 |
xml_parser_free($this->xml_obj); |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
return true; |
| 173 |
} |
| 174 |
|
| 175 |
function startHandler($parser, $name, $attribs){ |
| 176 |
$_content = array(); |
| 177 |
$_content['attrs'] = $name; |
| 178 |
array_push($this->output, $_content); |
| 179 |
} |
| 180 |
|
| 181 |
function dataHandler($parser, $data){ |
| 182 |
if($data!="\n") { |
| 183 |
$_output_idx = count($this->output) - 1; |
| 184 |
// echo $data."<br />"; |
| 185 |
$this->output[$_output_idx]['content'] = $data; |
| 186 |
} |
| 187 |
} |
| 188 |
|
| 189 |
function endHandler($parser, $name){ } |
| 190 |
} |
| 191 |
|
| 192 |
$p =& new xmlParser(); |
| 193 |
$p->parse($currentfile); |
| 194 |
$a = $p->output; |
| 195 |
|
| 196 |
for($i=1;$i<count($a);$i++) |
| 197 |
{ |
| 198 |
echo "<b>".ucfirst(strtolower($a[$i]['attrs']))." : </b>".$a[$i]['content']."<br />"; |
| 199 |
} |
| 200 |
?> |
| 201 |
</p> |
| 202 |
<p> |
| 203 |
<input type="hidden" name="MAX_FILE_SIZE" value="30000" /> |
| 204 |
<!-- Name of input element determines name in $_FILES array --> |
| 205 |
Check this file: |
| 206 |
<input name="userfile" type="file" size="70" /> |
| 207 |
</p> |
| 208 |
<p> |
| 209 |
<input type="submit" value=">> Check Style" /> |
| 210 |
</p> |
| 211 |
</form> |
| 212 |
</td> |
| 213 |
</tr> |
| 214 |
</table> |
| 215 |
</body> |
| 216 |
</html> |